I have an array of points by using getPart on each of the four polygons in the shapefile. I am trying to figure out a way to create a list of x and y coordinates in my for loop and name them xCoords and yCoords so I can plug them into my functions to calculate the perimeter. For some reason, I can't seem to make a list that separates the x and y points... any ideas?
Note: When I print point.X or point.Y, it gives me one coordinate. I know that I have to write some code in my for loop to get separate lists of x and y coordinates for each polygon, I'm just not sure how to.
import arcpy, os
from arcpy import env
from arcpy.sa import *
from math import *
env.workspace = r"H:\GEOG 4303\cho_lab4\lab4\data"
env.overwriteOutput = 1
theme = 'watersheds_3D.shp'
DEM = 'demlab4'
cursor = arcpy.da.SearchCursor(theme, ["SHAPE@", "Id"])
for row in cursor:
array = arcpy.Array()
print("Polygon Id: {0}".format(row[1]))
for Id in row[0].getPart():
print("Polygon coordinates: {0}".format(Id.count))
for point in Id:
print("X: {0}, Y: {1}".format(point.X, point.Y))
array.add(arcpy.Point(point.X, point.Y))
print array
arcpy.Polygon
which is the object in your row object as the first element, already haslength
property. Please see desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-classes/…