#python #dataframe #geojson #geopandas #shapely
Вопрос:
У меня есть геодезическая рамка:
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))
. Теперь я хочу преобразовать его обратно.
Какой-нибудь простой взлом?
Ответ №1:
shape()
функция преобразует его обратно:
gdf['geometry'] = gdf['geometry'].apply(lambda x: shapely.geometry.shape(x))