此文为通过边界(线或者点集合)获得栅格数据的Z值,可以用来求raster数据的高程,不过和原始像元值有1-5之间的相差,如果你的程序要求没有那么严格,可以用此方法,如果要求严格,你可以参考我的博文——通过extract values to points来获得高程
/// <summary>
/// 获得高程(Z值)/// </summary>
/// <param name="rasterPath">栅格数据路径</param>
/// <param name="inFeatureToLine">面转化为线的路径</param>
/// <returns></returns>
private List<int> GetZValue(string rasterPath, string inFeatureToLine)
{
try
{
List<int> z = new List<int>();
//得到raster
IRaster raster = GetRaster(rasterPath);//参考博文获得raster
//得到点集合
List<IPoint> pointCol = GetPointCollection(inFeatureToLine);//参考博文获得点集合
IRasterSurface rasterSurface = new RasterSurfaceClass();
rasterSurface.PutRaster(raster, 0);
ISurface surface = (ISurface)rasterSurface;
for (int i = 0; i < pointCol.Count; i++)
{
//得到边界的Z值集合
z.Add((int)surface.GetElevation(pointCol[i]));
}
return z;
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
return null;
}
}
本文参考了http://www.gissky.net/Article/1666.htm,感谢