ArcGIS Engine获取栅格数据统计值
ArcGIS提供获取栅格数据最大最小值的接口,使用IRasterStatistics接口,其包含Maximum、Minimum属性代表最大最小值。
由于最大最小值获取与波段相关,每个波段都有其最大最小值,因此最大最小值获取要使用各个波段接口获得。
方法步骤:
- 获取栅格图层IRasterLayer
- 从栅格图层获得栅格数据IRaster
- 将栅格数据转为栅格波段集IRasterBandCollection
- 从波段数据集获取单一波段IRasterBand
- 从波段获得栅格统计数据
获取IRasterLayer
ILayer pLayer = axMapControl1.get_Layer(3);
IRasterLayer pRasterLayer = pLayer as IRasterLayer; //图层转栅格图层
从栅格图层获得栅格数据IRaster
IRaster pRaster = pRasterLayer.Raster; //获得栅格数据
将栅格数据转为栅格波段集IRasterBandCollection
IRasterBandCollection pRasterBC = (IRasterBandCollection)pRaster;
从波段数据集获取波段IRasterBand
IRasterBand pRB = pRasterBC.Item(0); //获取栅格波段
从波段获得栅格统计数据
IRasterStatistics pRasterStat = pRB.Statistics; //获取统计数据
double max = pRasterStat.Maximum;
double min = pRasterStat.Minimum;
全部代码:
ILayer pLayer = axMapControl1.get_Layer(3);
IRasterLayer pRasterLayer = pLayer as IRasterLayer;
//获取波段信息
IRaster pRaster = pRasterLayer.Raster;
IRasterBandCollection pRasterBC = (IRasterBandCollection)pRaster;
IRasterBand pRB = pRasterBC.Item(0); //获取栅格波段
IRasterStatistics pRasterStat = pRB.Statistics; //获取统计数据
double max = pRasterStat.Maximum;
double min = pRasterStat.Minimum;
转载自:https://blog.csdn.net/ScapeD/article/details/82874791