工具箱相关
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

PolygonZX.py 878B

1234567891011121314151617181920212223
  1. import arcpy
  2. import math
  3. def ZXpoint(shppath,outpath):
  4. txtpath = outpath + '\\ZXpoint.txt'
  5. arcpy.MakeFeatureLayer_management(shppath, 'SHP')
  6. with open(txtpath,'w') as line:
  7. with arcpy.da.SearchCursor('SHP', ['SHAPE@', '宗地编号']) as cursorA:
  8. for curA in cursorA:
  9. zdbh = curA[1]
  10. shp1 = curA[0]
  11. #中心点的计算
  12. ceny = (shp1.extent.YMax + shp1.extent.YMin)/2
  13. cenx = (shp1.extent.XMax + shp1.extent.XMin)/2
  14. line.write(zdbh + ':' + str(round(cenx,4)) + ',' + str(round(ceny,4)))
  15. line.write('\n')
  16. if __name__ == '__main__':
  17. try:
  18. # 输入shp,输出界址点文件夹
  19. ZXpoint(arcpy.GetParameterAsText(0),arcpy.GetParameterAsText(1))
  20. except arcpy.ExecuteError:
  21. arcpy.AddMessage(arcpy.GetMessages())