通过点获取栅格值
作者:互联网
/// <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);
}
}
标签:point,double,通过,surface,height,栅格,获取,new 来源: https://www.cnblogs.com/wzyong/p/16066454.html