本文以线状地物宽度赋值的脚本为例,试说明在ArcGIS中如何创建自定义地理处理工具。
2InputFeature=arcpy.GetParameterAsText(0)
3
4arcpy.AddMessage("------------------------------------------------------")
5arcpy.AddMessage("Ifyouencounterdifficulties,pleasesendanemailtozhangyhcumt@163.com")
6arcpy.AddMessage("------------------------------------------------------")
7
8#Createthreenewfields
9arcpy.AddField_management(InputFeature,"MJ","DOUBLE")
10arcpy.AddField_management(InputFeature,"ZC","DOUBLE")
11arcpy.AddField_management(InputFeature,"XZDWKD","DOUBLE")
12
13
14arcpy.AddMessage("Step1NewField")
15
16
17#Fieldscalculation
18arcpy.CalculateField_management(InputFeature,"MJ","!Shape.area!","PYTHON_9.3")
19arcpy.CalculateField_management(InputFeature,"ZC","!Shape.length!","PYTHON_9.3")
20arcpy.CalculateField_management(InputFeature,"XZDWKD","!ZC!/4-math.sqrt(!ZC!*!ZC!/16-!MJ!)","PYTHON_9.3")
21
22
23arcpy.AddMessage("Step2Fieldcalculation")
24
25
26arcpy.DeleteField_management(InputFeature,"MJ")
27arcpy.DeleteField_management(InputFeature,"ZC")
28
29arcpy.AddMessage("Step3Successful")
30arcpy.AddMessage("------------------------------------------------------")
GetParameterAsText:用来将参数列表中的索引位置以文本字符串的形式获取指定参数
如何在ArcGIS中创建自定义地理处理工具
本文来自投稿,不代表本站立场,如若转载,请注明出处: