/// <summary>
/// 通过点获取栅格值
/// </summary>
/// <param name="raster">栅格对象</param>
/// <param name="point">点对象</param>
/// <returns></returns>
public static double GetHeigtByPoint(IRaster raster, double x, double y)
{
return 0;
double height;
IPoint point = new PointClass();
point.X = x;
point.Y = y;
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;
//获取高程
height = surface.GetElevation(point);
}
else
{
//ptX = point.X;
//ptY = point.Y;
//获取高程
point.Project(spatialreference);
height = surface.GetElevation(point);
}
return height;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
通过点获取栅格值
最新推荐文章于 2024-08-20 12:01:28 发布