top of page

Perimeter and Area

The Python script determines the perimeter (in meters ) and area (in square meters ) of each of the individual islands of a multipart feature class.

# Ehsan Momeni

from arcpy import env, Describe, da, Polygon


env.workspace = r"C:\Users\emomeni\"  # Shapefile sources
fc = "Hawaii.shp"  # Input shapefile

SR = Describe(fc).spatialReference  #spatial references
units = SR.linearUnitName  # linear unit name

cursor = da.SearchCursor(fc, ["OID@", "SHAPE@"])
for OID, shape in cursor:
    partnum = 0
    for part in shape:
        pn = Polygon(part, SR)
        print "{}: Area:{} {}^2\tPerimeter:{} {}".format( partnum, pn.area, units, pn.length, units)
        partnum += 1
    print "\nTotal Area:{} {}^2".format(shape.area, units)

google_scholar1-300x150.png
ResearchGate.png
Ehsan Momeni ORCID GIS Remote Sensing Ur
Ehsan Momeni LinkedIn GIS Remote Sensing
ncbi-300x150.png
academia.png

(Information on this website may not be up to date)

bottom of page