C#中使用IMapAlgebraOp接口和RasterMapAlgebraOp类进行栅格计算并将结果显示在mapcontorl中的具体流程用文字详细的描述
-
首先,需要添加ESRI.ArcGIS.SpatialAnalyst引用,以便使用IMapAlgebraOp接口和RasterMapAlgebraOp类。
-
在代码中实例化IMapAlgebraOp接口和RasterMapAlgebraOp类。
IMapAlgebraOp mapAlgebra = new RasterMapAlgebraOp();
- 构建栅格计算表达式,例如:
string expression = "Con((" + rasterLayer1.FilePath + " > 0), " + rasterLayer1.FilePath + " * " + rasterLayer2.FilePath + ", 0)";
其中,rasterLayer1和rasterLayer2是已经加载到mapcontrol中的两个栅格图层,expression是栅格计算表达式。
- 调用IMapAlgebraOp接口的Execute方法,执行栅格计算。
IRaster rasterResult = mapAlgebra.Execute(expression);
- 将计算结果添加到mapcontrol中。
IRasterLayer rasterLayerResult = new RasterLayerClass(); rasterLayerResult.CreateFromRaster(rasterResult); mapControl.AddLayer(rasterLayerResult);
- 刷新mapcontrol。
mapControl.Refresh();
以上是使用IMapAlgebraOp接口和RasterMapAlgebraOp类进行栅格计算,并将结果显示在mapcontrol中的具体流程
原文地址: http://www.cveoy.top/t/topic/ebvS 著作权归作者所有。请勿转载和采集!