Reputation: 159
I have a shapefile of US Cities and I want to get the X and Y coordinate of EACH city in that shapefile. I've tried this:
for city in city_cursor:
geom = city.Shape
point = geom.getPart()
citylist_City_Name.append(city.CITY_NAME)
citylist_Country.append(city.CNTRY_NAME)
citylist_Admin.append(city.ADMIN_NAME)
citylist_Population.append(city.Population)
citylist_X_Coor.append(geom.point.X)
citylist_Y_Coor.append(geom.point.Y)
but I get the error
Traceback (most recent call last): File "C:/Users/workd.py", line 43,
in citylist_X_Coor.append(geom.point.X) AttributeError: 'PointGeometry' object
has no attribute 'point'
I don't really understand the error message? How can I fix it? Thanks!
Upvotes: 0
Views: 580
Reputation: 63709
Now that I can read your code, you probably want to change:
citylist_X_Coor.append(geom.point.X)
citylist_Y_Coor.append(geom.point.Y)
to
citylist_X_Coor.append(point.X)
citylist_Y_Coor.append(point.Y)
since you already extracted point
from geom
using geom.getPart()
.
Upvotes: 1