将 GeoJSON 对象转换为形状对象

Converting GeoJSON object to shapely object

我有一个地理数据框:

gdf
                              name  ...                                           geometry
0     INET_PL_273_EE_0_Seg_0_Seg_0  ...  {'type': 'LineString', 'coordinates': [[23.896...
1     INET_PL_273_EE_1_Seg_0_Seg_0  ...  {'type': 'LineString', 'coordinates': [[22.241...
2          INET_PL_357_Seg_0_Seg_0  ...  {'type': 'LineString', 'coordinates': [[13.592...
3          INET_PL_359_Seg_0_Seg_0  ...  {'type': 'LineString', 'coordinates': [[13.592...
4          INET_PL_361_Seg_0_Seg_0  ...  {'type': 'LineString', 'coordinates': [[13.592...
...                            ...  ...                                                ...
6318       EntsoG_Map__ST_25_Seg_0  ...  {'type': 'LineString', 'coordinates': [[13.887...
6319       EntsoG_Map__ST_26_Seg_0  ...  {'type': 'LineString', 'coordinates': [[23.080...
6320       EntsoG_Map__ST_26_Seg_0  ...  {'type': 'LineString', 'coordinates': [[6.7552...
6321      EntsoG_Map__ST_448_Seg_0  ...  {'type': 'LineString', 'coordinates': [[25.348...
6322      EntsoG_Map__ST_449_Seg_0  ...  {'type': 'LineString', 'coordinates': [[25.348...
[6323 rows x 7 columns]

我通过 gdf['geometry'] = gdf['geometry'].apply(lambda x: shapely.geometry.mapping(x)) 创建了几何列。现在我想把它转换回来。

任何简单的技巧?

shape() 函数将其转换回:

gdf['geometry'] = gdf['geometry'].apply(lambda x: shapely.geometry.shape(x))