0

我有一个美国城市的 shapefile,我想在该 shapefile 中获取每个城市的 X 和 Y 坐标。我试过这个:

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)

但我得到了错误

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'

我真的不明白错误信息?我该如何解决?谢谢!

4

1 回答 1

1

现在我可以阅读您的代码,您可能想要更改:

citylist_X_Coor.append(geom.point.X) 
citylist_Y_Coor.append(geom.point.Y)

citylist_X_Coor.append(point.X) 
citylist_Y_Coor.append(point.Y)

因为你已经pointgeomusing中提取了geom.getPart()

于 2013-05-04T06:20:46.017 回答