获取点坐标和高程(C# +ArcEngine93)
获取点坐标和高程(C# +ArcEngine93)程序说明:1.需要一个带坐标系的栅格数据.2.关键程序很简单,用关键接口ISurface,方法用ISurface.GetElevation(). 程序下载 关键代码如下: /// /// 获取x,y,高程值 /// /// ...
- 作者:JinDin来源:ESRI|2009年08月05日
获取点坐标和高程(C# +ArcEngine93)
程序说明:
1.需要一个带坐标系的栅格数据.
2.关键程序很简单,用关键接口ISurface,方法用ISurface.GetElevation().
关键代码如下:
- /// <summary>
- /// 获取x,y,高程值
- /// </summary>
- /// <param name="raster"></param>
- /// <param name="point"></param>
- /// <param name="ptX"></param>
- /// <param name="ptY"></param>
- /// <param name="ptHeight"></param>
- void getXYAndHeight(IRaster raster, IPoint point, out double ptX, out double ptY, out double ptHeight)
- {
- ptX = 0.0;
- ptY = 0.0;
- ptHeight = 0.0;
- try
- {
- IGeoDataset geoDt = raster as IGeoDataset;
- ISpatialReference spatialreference = geoDt.SpatialReference;
- IRasterSurface rasterSurface = new RasterSurfaceClass();
- rasterSurface.PutRaster(raster, 0);
- ISurface surface = rasterSurface as ISurface;
- if (point.SpatialReference == null)
- {
- point.Project(spatialreference);
- ptX = point.X;
- ptY = point.Y;
- //获取高程
- ptHeight = surface.GetElevation(point);
- }
- else
- {
- ptX = point.X;
- ptY = point.Y;
- //获取高程
- point.Project(spatialreference);
- ptHeight = surface.GetElevation(point);
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
希望能给初学者一点帮助.
程序做得不是很完善,欢迎各位修改,提意见.
+ hot
热门推荐