GP下CalculateField的用法

2019-07-04

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)), "\"\"");

GP下CalculateField的用法

GP下CalculateField的用法

原文地址:https://www.cnblogs.com/yzhyingcool/p/11135597.html