【发布时间】:2021-09-22 16:13:28
【问题描述】:
我正在尝试将文本文件中的数据(按纬度、经度和花粉通量值组织)绘制为 Python 中的栅格网格。我在https://autogis-site.readthedocs.io/en/latest/notebooks/L5/02_interactive-map-folium.html 上使用Choropleth Map 的代码来尝试显示数据。我的 GeoPandas 地理数据框有点几何;但是,看起来教程中点的几何形状已经是多面体,我假设是网格中的正方形。如何将我的数据(假设每个纬度/经度点是网格中像素的中心)转换为网格化 geopandas(地理数据框)数据?我将使用的投影是 Lambert Conformal Conic 投影。
为了澄清我的地理数据框是什么样子,在执行 gdf.head(10).to_dict() 时,它看起来像这样
{'geoid': {0: '0',
1: '1',
2: '2',
3: '3',
4: '4',
5: '5',
6: '6',
7: '7',
8: '8',
9: '9'},
'geometry': {0: <shapely.geometry.point.Point at 0x7fa3e7feee90>,
1: <shapely.geometry.point.Point at 0x7fa3e7feed10>,
2: <shapely.geometry.point.Point at 0x7fa3e7feef90>,
3: <shapely.geometry.point.Point at 0x7fa3e7fe4f90>,
4: <shapely.geometry.point.Point at 0x7fa3e7fe4e50>,
5: <shapely.geometry.point.Point at 0x7fa3e7fe4bd0>,
6: <shapely.geometry.point.Point at 0x7fa3e7fe4ed0>,
7: <shapely.geometry.point.Point at 0x7fa3e7fe4c90>,
8: <shapely.geometry.point.Point at 0x7fa3e7fe4d50>,
9: <shapely.geometry.point.Point at 0x7fa3e7fe4c10>},
'pollenflux': {0: 0.0,
1: 0.0,
2: 0.0,
3: 0.0,
4: 0.0,
5: 0.0,
6: 0.0,
7: 0.0,
8: 0.0,
9: 0.0}}
什么时候应该这样格式化:
{'geoid': {0: '0',
1: '1',
2: '2',
3: '3',
4: '4',
5: '5',
6: '6',
7: '7',
8: '8',
9: '9'},
'geometry': {0: <shapely.geometry.multipolygon.MultiPolygon at 0x7fa3e9363f50>,
1: <shapely.geometry.multipolygon.MultiPolygon at 0x7fa3e9363c90>,
2: <shapely.geometry.multipolygon.MultiPolygon at 0x7fa3e93631d0>,
3: <shapely.geometry.multipolygon.MultiPolygon at 0x7fa3e9363f10>,
4: <shapely.geometry.multipolygon.MultiPolygon at 0x7fa3e9363410>,
5: <shapely.geometry.multipolygon.MultiPolygon at 0x7fa3e9363a90>,
6: <shapely.geometry.multipolygon.MultiPolygon at 0x7fa3e9363d90>,
7: <shapely.geometry.multipolygon.MultiPolygon at 0x7fa3e9363d10>,
8: <shapely.geometry.multipolygon.MultiPolygon at 0x7fa3e9363390>,
9: <shapely.geometry.multipolygon.MultiPolygon at 0x7fa3e9363190>},
'pop18': {0: 108,
1: 273,
2: 239,
3: 202,
4: 261,
5: 236,
6: 121,
7: 196,
8: 397,
9: 230}}
【问题讨论】:
-
您能否在您的问题中发布
gdf.head(10).to_dict()的结果,以便我们重现该问题?
标签: python data-visualization raster geopandas geography