将类似GeoJSON的字符串列转换为GeoPandas中的几何对象

问题描述 投票:0回答:2

我在GeoPandas数据框中有一列,其字符串类似于此'{type=Point, coordinates=[37.55, 55.71]}'或此'{type=MultiPoint, coordinates=[[37.6, 55.4]]}'。它可以是多边形或任何其他几何形状。然后有一些嵌套列表的形式。如何将其转换为普通的GeoPandas几何对象?

python geojson geopandas shapely
2个回答
0
投票

使用shapely.geometry.shape将geojson字符串转换为几何形状。

shapely.geometry.shape

0
投票

我实现了如下。感谢@martinfleis

from shapely.geometry import shape

df['geometry'] = df.apply(lambda: row: shape(row['jsoncolumn']), axis=1)
© www.soinside.com 2019 - 2024. All rights reserved.