GP下CalculateField的用法

以前用过这个类做字段计算,许久不用有些忘却,记录一下使用方式

   public static void CalculateField(IFeatureLayer featureLayer,IField field,string expression)
        {
           Geoprocessor gp = new Geoprocessor { OverwriteOutput = true };

           CalculateField cal = new CalculateField()
           {
               in_table =  featureLayer,
               field = field.Name,
               expression = expression,
               expression_type = "PYTHON_9.3"
           };
           gp.Execute(cal, null);
        }

调用时,如果expression为"",即空,需要这样使用:"\"\""

CalculateField(pFeatureLayer,pFeatureLayer.FeatureClass.Fields.get_Field( pFeatureLayer.FeatureClass.FindField( item.SubItems[1].Text)), "\"\"");

posted @ 2019-07-04 23:35  yzhyingcool  阅读(709)  评论(0编辑  收藏  举报