1

I am tasked with programmatically getting the area of each individual part of a multi-part feature. I have a script already to read each individual part and print its XY coordinates and it works fine but for some reason can't seem to modify it to also print the areas too.

I have tried inserting the SHAPE@AREA token but receive errors that the "Float object is not iterable". I'm sure it's something simple I am just missing but I can't seem to find an example of this for multipart features. I can write a simple code that gives me total area but not the area of each part. Any suggestions? Here is my script before I include the SHAPE@AREA

import arcpy
from arcpy import env
env.workspace = "C:/Data/Exercise08"
fc = "Hawaii.shp"
cursor = arcpy.da.SearchCursor(fc, ["OID@", "SHAPE@"])
for row in cursor:
 print("Feature {0}: ".format(row[0]))
 partnum = 0
 for part in row[1]:
 print("Part {0}: ".format(partnum))
 for point in part:
 print("{0}, {1}".format(point.X, point.Y))
 partnum += 1
PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Oct 31, 2013 at 16:00

1 Answer 1

8

You can actually deal with each part of a multipart polygon by creating a separate polygon object. Take a look at the following code.

import arcpy
from arcpy import env
env.workspace = "C:/Data/Exercise08"
fc = "Hawaii.shp"
for row in arcpy.da.SearchCursor(fc, ["OID@", "SHAPE@"]):
 print("Feature {0}: ".format(row[0]))
 partnum = 0
 for part in row[1]:
 poly = arcpy.Polygon(part) # <--Create polygon object from part
 print("Part {0} area: {1}".format(partnum, poly.area))
 partnum += 1
answered Oct 31, 2013 at 17:43
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.