Converting a column of Polygons from string to GeoPandas geometry Converting a column of Polygons from string to GeoPandas geometry python python

Converting a column of Polygons from string to GeoPandas geometry


The format of your polygon is WKT, so you have to convert it to shapely Polygon. Following Geopandas docs (https://geopandas.readthedocs.io/en/latest/gallery/create_geopandas_from_pandas.html) do following

Using GeoPandas 0.9+:

df['geometry'] = gpd.GeoSeries.from_wkt(df['geometry'])my_geo_df = gpd.GeoDataFrame(my_df, geometry='geometry')

Using older versions:

from shapely import wktdf['geometry'] = df['geometry'].apply(wkt.loads)my_geo_df = gpd.GeoDataFrame(my_df, geometry='geometry')