Last active
August 29, 2015 14:02
-
-
Save knu2xs/3de2b99f924082f7de76 to your computer and use it in GitHub Desktop.
Get centroid of an entire feature class
This file contains hidden or 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 modules | |
| import arcpy | |
| # set variables to make life easier | |
| fc = "Wilderness" | |
| def get_centroid(feature_class): | |
| # use describe to create an extent obejct to work with | |
| extent = arcpy.Describe(feature_class).extent | |
| # calculate centroid using a little arithmitic | |
| centroid_x = extent.XMax - extent.XMin + extent.XMin | |
| centroid_y = extent.YMax - extent.YMin + extent.YMin | |
| # return the result as a tuple | |
| return [centroid_y, centroid_x] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment