使用Geoprocessor 计算面积和长度

来自:http://blog.csdn.net/tianxinzhe032/article/details/6660051   

/// <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);
        }

你可能感兴趣的:(process)