Python Geopandas-计算x、y对数的简单方法

Python Geopandas-计算x、y对数的简单方法,python,gis,geopandas,Python,Gis,Geopandas,我有一个geopandas数据帧: import geopandas as gp shp = gp.GeoDataFrame.from_file('example_file.shp') shp.head(1) SHAPE_LEN, SHAPE_AREA, geometry 21685 1.400 POLYGON ((-94.56994242128158 39.0135784915016, -94.56996218461458 39.01306817553366, -94.

我有一个geopandas数据帧:

import geopandas as gp
shp = gp.GeoDataFrame.from_file('example_file.shp')
shp.head(1)

SHAPE_LEN, SHAPE_AREA, geometry
21685      1.400       POLYGON ((-94.56994242128158 39.0135784915016, -94.56996218461458 39.01306817553366, -94.57042915800061 39.0130911485529, -94.57226806507019 39.01315884549675, -94.57342610723566 39.0132037014107, -94.57455413213843 39.01325045956409, -94.5744687494557 39.0149606326803, -94.57438658848373 39.01662549877073, -94.57429668454471 39.01829429564054, -94.57420188567131 39.01996471505225, -94.57409920172726 39.02177363299919, -94.57399716984756 39.02357145717905, -94.57389471998749 39.02537842422011, -94.57379374134878 39.02718338530785, -94.5736922385682 39.02899696762881, -94.57358427357126 39.03083007540815, -94.57347404106743 39.03265453494053, -94.5733651179229 39.03445691515196))
是否有一种简单的方法来获取“几何体”字段中x,y坐标对的数量?使用len这样简单的操作会引发以下错误:

print (len(shp.geometry.iloc[0])) throws the following error:

TypeError: object of type 'Polygon' has no len()
是否需要转换“几何体”列的类型


要获得x,y坐标对的数量,非常感谢任何帮助

import geopandas as gp

shp = gp.GeoDataFrame.from_file('example_file.shp') 

def get_coord(coord):
  return (coord.x, coord.y)

centroidseries = shp['geometry'].centroid
xycoords = map(get_coord, centroidseries)
或者,如果需要两个单独的x和y坐标列表:

x,y = [list(t) for t in zip(*map(get_coord, centroidseries))]