I need to add a polygon for each bookmark (which works fine) and then attribute a field based off which Zip Codes the bookmark polygon intersects.
I dont know if I am on the right track. The code completes so there is no error to show you but the field for each polygon is empty.
Any help will be extremely grateful.
Thanks
cur = arcpy.da.InsertCursor(outFC, ["SHAPE@", "Zip Code"])array = arcpy.Array()for bkmk in arcpy.mapping.ListBookmarks(mxd): array.add(arcpy.Point(bkmk.extent.XMin, bkmk.extent.YMin)) array.add(arcpy.Point(bkmk.extent.XMin, bkmk.extent.YMax)) array.add(arcpy.Point(bkmk.extent.XMax, bkmk.extent.YMax)) array.add(arcpy.Point(bkmk.extent.XMax, bkmk.extent.YMin)) array.add(arcpy.Point(bkmk.extent.XMin, bkmk.extent.YMin)) polygon = arcpy.Polygon(array) # Calculate Zip Code arcpy.MakeFeatureLayer_management(zipCodesSHP, "zipCodesLYR") arcpy.SelectLayerByLocation_management("zipCodesLYR", "INTERSECT", polygon, "", "NEW_SELECTION") zipCodes = [row[0] for row in arcpy.da.SearchCursor ("zipCodesLYR", "Zip_Code")] zipCode = ", ".join("\"" + str(zipCodes) + "\"") # Insert polygon and information cur.insertRow([polygon, zipCodes]) array.removeAll()
أكثر...
I dont know if I am on the right track. The code completes so there is no error to show you but the field for each polygon is empty.
Any help will be extremely grateful.
Thanks
cur = arcpy.da.InsertCursor(outFC, ["SHAPE@", "Zip Code"])array = arcpy.Array()for bkmk in arcpy.mapping.ListBookmarks(mxd): array.add(arcpy.Point(bkmk.extent.XMin, bkmk.extent.YMin)) array.add(arcpy.Point(bkmk.extent.XMin, bkmk.extent.YMax)) array.add(arcpy.Point(bkmk.extent.XMax, bkmk.extent.YMax)) array.add(arcpy.Point(bkmk.extent.XMax, bkmk.extent.YMin)) array.add(arcpy.Point(bkmk.extent.XMin, bkmk.extent.YMin)) polygon = arcpy.Polygon(array) # Calculate Zip Code arcpy.MakeFeatureLayer_management(zipCodesSHP, "zipCodesLYR") arcpy.SelectLayerByLocation_management("zipCodesLYR", "INTERSECT", polygon, "", "NEW_SELECTION") zipCodes = [row[0] for row in arcpy.da.SearchCursor ("zipCodesLYR", "Zip_Code")] zipCode = ", ".join("\"" + str(zipCodes) + "\"") # Insert polygon and information cur.insertRow([polygon, zipCodes]) array.removeAll()
أكثر...