arcgis属性表添加[length]、[area]字段

在arcgis矢量数据中添加[length]、[area]字段,无法进行字段计算器进行统一赋值,原因是length和area是保留字段?

posted on 2017-04-20 15:21 Gino森 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/kearney908/p/6738945.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
下面是一个Python 2.7的ArcGIS工具箱脚本,它会删除除Object ID、Shape和Shape_Length/Shape_Area字段外的所有字段: ```python import arcpy class Toolbox(object): def __init__(self): self.label = "Delete Extra Fields" self.alias = "Delete Extra Fields" # List of tool classes associated with this toolbox self.tools = [DeleteExtraFields] class DeleteExtraFields(object): def __init__(self): self.label = "Delete Extra Fields" self.description = "Deletes all fields except for Object ID, Shape, and Shape_Length/Shape_Area." self.canRunInBackground = False def getParameterInfo(self): params = [] # Input feature class parameter input_fc = arcpy.Parameter( name="input_fc", displayName="Input Feature Class", datatype="GPFeatureLayer", parameterType="Required", direction="Input") params.append(input_fc) return params def execute(self, parameters, messages): # Get the input feature class input_fc = parameters[0].valueAsText # Get a list of all the fields in the input feature class field_names = [field.name for field in arcpy.ListFields(input_fc)] # Loop through the fields and delete any fields that are not Object ID, Shape, or Shape_Length/Shape_Area for field_name in field_names: if not (field_name == "OBJECTID" or field_name == "SHAPE" or field_name == "SHAPE_Length" or field_name == "SHAPE_Area"): arcpy.DeleteField_management(input_fc, field_name) messages.addMessage("Extra fields deleted.") return ``` 要使用此工具箱脚本,请按照以下步骤操作: 1. 在ArcGIS创建一个新的工具箱。 2. 右键单击工具箱,并选择“添加脚本”。 3. 输入上面的代码,并保存脚本。 4. 在工具箱,右键单击脚本,并选择“属性”。 5. 在“参数”选项卡上,添加一个“GPFeatureLayer”类型的参数,命名为“input_fc”。 6. 保存属性并关闭窗口。 7. 现在您可以在工具箱使用此脚本。只需选择要处理的要素类,然后运行脚本即可删除所有除Object ID、Shape和Shape_Length/Shape_Area字段外的其他字段
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值