Created
January 19, 2018 16:02
-
-
Save hunterwei/b6954467e934b4abd471ed35ad33c566 to your computer and use it in GitHub Desktop.
A python script snippet to quickly get the extent of polygon feature(s)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import arcpy | |
LAYER_NAME="Your layer name" | |
FIELD_NAME="Your field name" | |
shapeFieldName = arcpy.Describe(LAYER_NAME).shapeFieldName | |
rows = arcpy.SearchCursor(LAYER_NAME) | |
for row in rows: | |
fieldValue = row.getValue(FIELD_NAME).strip() | |
feat = row.getValue(shapeFieldName) | |
extent = feat.extent | |
print "'{0}' : {{ 'xmin':{1}, 'ymin':{2}, 'xmax':{3}, 'ymax':{4} }}," | |
.format(fieldValue, extent.XMin, extent.YMin, extent.XMax, extent.YMax) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment