Reputation: 7245
I have a geopandas dataframe
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
where
gridDF['geometry'][0]
<shapely.geometry.polygon.Polygon at 0x7fa4cc6ccc50>
I would like to convert the entries in the column geometry
as a string.
Upvotes: 7
Views: 12683
Reputation: 3086
You can use apply if you want to do all rows at once.
from shapely import wkt
gridDF['str_geom'] = gridDF.geometry.apply(lambda x: wkt.dumps(x))
Upvotes: 7
Reputation: 421
I think you can use this function: shapely.wkt.dumps
Example:
from shapely import wkt
wkt_string = wkt.dumps(gridDF['geometry'][0])
print(wkt_string)
The wkt_string
should be the geometry as string in wkt format.
Upvotes: 0