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

Jam*_*ash 5 python geojson shapely geopandas

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

mar*_*eis 5

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

from shapely.geometry import shape

df['geometry'] = df.apply(lambda: row: shape(row['jsoncolumn']), axis=1)
Run Code Online (Sandbox Code Playgroud)