AnsweredAssumed Answered

Problem in calculation Area and Perimeter using Python

Question asked by on Dec 14, 2014
Latest reply on Dec 14, 2014 by

I need a script that determines the perimeter (in meters) and area (in square meters) of each of the individual islands of the Hawaii.shp feature class. This shapefile is multipart feature class.


My code illustrate below, but it doesn't give me correct answer ?


fc = r"D:\Python Exercise\Exercise08-2014-12-05\Exercise08\Hawaii.shp"

cursor = arcpy.da.SearchCursor(fc, ["OID@","SHAPE@","SHAPE@AREA","SHAPE@LENGTH"])

units = arcpy.Describe(fc).spatialReference.linearUnitName



for row in cursor:

    print "Total Area: ", row[2]

    print("Feature {0}: ".format(row[0]))

    partnum = 0

    perimeter = 0

    for part in row[1]:

        print("Part {0}: ".format(partnum))

        for point in part:

            perimeter += row[3]

        partnum += 1

        #print "Area: ", row[2]

        print "Perimeter: ", perimeter, units