ArcGIS shape_area 出现负值解决办法

       今天发现在arcgis中,图层的面积属性shape_area竟然出现了负值,想必是数据转换的时候出现了问题。经过搜索找到了解决办法。
       ArcGIS默认顺时针图形为正,手工画polygon的时候不管怎么画结果都是顺时针的。所以一般负值的出现是转换过程出现问题,polygon是由ring组成的,ring则是有更小的segement(line,circularArc,ellipticalArc,beziercurve)构成,所具有方向性。
       解决方法是用ArcTool中的check geometry和 repair geometry工具,上述的检查结果是Incorrect ring ordering。repair后会自动修复错误。
下面是一个Python 2.7的ArcGIS工具箱脚本,它会删除除Object ID、ShapeShape_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、ShapeShape_Length/Shape_Area字段外的其他字段。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值