提取shp四至坐标
2019-04-13 本文已影响0人
峤桓
利用ArcGIS提取shp四至坐标,以下是源代码。
# -*- coding: utf-8 -*-
# Import arcpy module
import arcpy
Shp = arcpy.GetParameterAsText(0)
if Shp == '#' or not Shp:
Shp ="shp" # provide a default value if unspecified
maxX = Shp
maxY = maxX
minX = maxY
minY = minX
minYC = minY
minXC = minYC
maxYC = minXC
maxXC = maxYC
arcpy.AddField_management(Shp,"maxX", "TEXT", "", "", "50", "", "NULLABLE", "NON_REQUIRED", "")
arcpy.AddField_management(maxX,"maxY", "TEXT", "", "", "50", "", "NULLABLE", "NON_REQUIRED", "")
arcpy.AddField_management(maxY,"minX", "TEXT", "", "", "50", "", "NULLABLE", "NON_REQUIRED", "")
arcpy.AddField_management(minX,"minY", "TEXT", "", "", "50", "", "NULLABLE", "NON_REQUIRED", "")
arcpy.CalculateField_management(minY,"minY", "!shape.extent.ymin!", "PYTHON_9.3", "")
arcpy.CalculateField_management(minYC,"minX", "!shape.extent.xmin!", "PYTHON_9.3", "")
arcpy.CalculateField_management(minXC,"maxY", "!shape.extent.ymax!", "PYTHON_9.3", "")
arcpy.CalculateField_management(maxYC,"maxX", "!shape.extent.xmax!", "PYTHON_9.3", "")