You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何将GeoDataFrame中GeoJSON格式geometry列转换回shapely对象

实现方案

直接使用shapely内置的shape方法即可完成GeoJSON字典到shapely几何对象的转换,仅需一行apply操作:

from shapely.geometry import shape

# 直接转换geometry列
gdf['geometry'] = gdf['geometry'].apply(shape)

如果需要恢复为标准可调用空间方法的GeoDataFrame,可额外执行一步类型重置:

import geopandas as gpd
gdf = gpd.GeoDataFrame(gdf, geometry='geometry')

该方法兼容所有标准GeoJSON几何类型,无需额外做类型适配判断。

内容的提问来源于stack exchange,提问作者oakca

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.06 14:09:01