Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Geopandas:如何将柱几何图形转换为字符串?_Python_Pandas_Geopandas_Shapely - Fatal编程技术网

Python Geopandas:如何将柱几何图形转换为字符串?

Python Geopandas:如何将柱几何图形转换为字符串?,python,pandas,geopandas,shapely,Python,Pandas,Geopandas,Shapely,我有一个geopandas数据帧 geometry idx 0 POLYGON ((-74.25559 40.91553, -74.24559 40.915... 0 1 POLYGON ((-74.25559 40.90553, -74.24559 40.905... 1 2 POLYGON ((-74.25559 40.89553, -74.24559 40.895... 2

我有一个geopandas数据帧

    geometry                                           idx
0   POLYGON ((-74.25559 40.91553, -74.24559 40.915...   0
1   POLYGON ((-74.25559 40.90553, -74.24559 40.905...   1
2   POLYGON ((-74.25559 40.89553, -74.24559 40.895...   2
3   POLYGON ((-74.25559 40.88553, -74.24559 40.885...   3
4   POLYGON ((-74.25559 40.87553, -74.24559 40.875...   4
在哪里

gridDF['geometry'][0]

我想将列
几何体中的条目转换为字符串。

我想您可以使用此函数:

例如:

from shapely import wkt
wkt_string = wkt.dumps(gridDF['geometry'][0])
print(wkt_string)

wkt\u字符串
应该是wkt格式的几何体字符串。

如果要同时执行所有行,可以使用apply

from shapely import wkt
gridDF['str_geom'] = gridDF.geometry.apply(lambda x: wkt.dumps(x))
from shapely import wkt
gridDF['str_geom'] = gridDF.geometry.apply(lambda x: wkt.dumps(x))