如何在忽略Geometry的情况下将GeoJSON Feature Collection转为Pandas DataFrame
只提取GeoJSON Feature Collection的properties到DataFrame
直接用pandas.json_normalize处理整个features列表会把geometry也带进来,你可以先单独提取每个feature里的properties字段,再转成DataFrame:
import pandas as pd # 假设你的Feature Collection对象存在fc变量里 properties_only = [feat['properties'] for feat in fc['features']] df = pd.json_normalize(properties_only)
原理很简单:原来的代码是把每个完整的Feature对象(包含geometry和properties)传给json_normalize,自然会解析所有字段。先把每个Feature里的properties单独抽出来组成新列表,再用json_normalize处理,就只会保留你需要的属性数据,完全跳过geometry。
内容的提问来源于stack exchange,提问作者Robbert
相关产品推荐
相关产品推荐

