/// <summary>
/// 计算多边形面积
/// </summary>
/// <param name="inputPath"></param>
/// <param name="outputPath"></param>
public static void CalculateAreas(string inputPath, string outputPath)
{
ESRI.ArcGIS.Geoprocessor.Geoprocessor GP = new ESRI.ArcGIS.Geoprocessor.Geoprocessor();
ESRI.ArcGIS.SpatialStatisticsTools.CalculateAreas calculate =
new ESRI.ArcGIS.SpatialStatisticsTools.CalculateAreas();
calculate.Input_Feature_Class = inputPath;
calculate.Output_Feature_Class = outputPath;
GP.OverwriteOutput = true;
GP.Execute(calculate, null);
}
/// <summary>
/// 计算线段长度
/// </summary>
/// <param name="path"></param>
/// <param name="field"></param>
public static void CalculateLength(string path, string field)
{
ESRI.ArcGIS.Geoprocessor.Geoprocessor GP= new ESRI.ArcGIS.Geoprocessor.Geoprocessor();
GP.OverwriteOutput = true;
CalculateField calfield = new CalculateField();
calfield.in_table = path;
if (field.Equals(""))
calfield.field = "F_LENGTH";
else
calfield.field = field;
calfield.expression = "!Shape.Length!";
calfield.expression_type = "PYTHON";
GP.Execute(calfield, null);
}
使用Geoprocessor 计算面积和长度
最新推荐文章于 2024-07-03 22:07:40 发布
本文介绍如何使用 ArcGIS API 计算地理空间数据中多边形的面积及线段的长度,并提供了具体的 C# 实现代码。通过两个实用函数实现自动化计算,适用于 GIS 数据处理场景。
400

被折叠的 条评论
为什么被折叠?



