## set the workspace ## enter your own path import arcpy import os from arcpy import env arcpy.env.workspace = r'C:\Users\cora\thesis\example.gdb' arcpy.env.overwriteOutput = True ## import KMZ created in GE def kmz_drama(): kmz_in = r'C:\Users\cora\thesis\example\original_poly.kmz' kmz_out = r'C:\Users\cora\thesis\example\poly' arcpy.KMLToLayer_conversion(kmz_in, kmz_out, 'all_feats_not_proj') kmz_drama() ## project to UTM Zone 37, northern hemisphere def project(): polygons = r'C:\Users\cora\thesis\example\poly\all_feats_not_proj.gdb' all_feats_proj = r'C:\Users\cora\thesis\example\poly\all_feats_proj.shp' UTM_37 = arcpy.SpatialReference('WGS_1984_UTM_Zone_37N') arcpy.management.Project(polygons, all_feats_proj, UTM_37) project() ## minimum bounding geometry def MBG(): all_feats_MBG = r'C:\Users\cora\thesis\example\all_feats_MBG.shp' arcpy.management.MinimumBoundingGeometry(r'C:\Users\cora\thesis\example\poly\all_feats_proj.shp', all_feats_MBG, 'RECTANGLE_BY_AREA') MBG() x = r'C:\Users\cora\thesis\example\poly\all_feats_proj.shp' def centers(arg): arcpy.management.AddField(arg, "x_coord", "DOUBLE") arcpy.management.AddField(arg, "y_coord", "DOUBLE") arcpy.management.CalculateGeometryAttributes(arg, [["x_coord", "CENTROID_X"],["y_coord","CENTROID_Y"]]) centers(x)