探索与可视化空间数据及其属性

在 Python 中处理地理空间数据

Joris Van den Bossche

Open source software developer and teacher, GeoPandas maintainer

筛选数据

countries.head()
          name      continent       gdp                            geometry
0  Afghanistan           Asia   64080.0  POLYGON ((61.21 35.65, 62.23 35...
1       Angola         Africa  189000.0  MULTIPOLYGON (((23.90 -11.72, 2...
...
countries['continent'] == 'Africa'
0      False
1       True
         ...  
175     True
176     True
Name: continent, Length: 177, dtype: bool
在 Python 中处理地理空间数据

筛选数据

countries_africa = countries[countries['continent'] == 'Africa']
countries_africa.plot()

在 Python 中处理地理空间数据

可视化空间数据

countries.plot()

在 Python 中处理地理空间数据

调整颜色:统一颜色

countries.plot(color="red")

在 Python 中处理地理空间数据

调整颜色:基于属性值

countries.plot(column='gdp_per_cap')

在 Python 中处理地理空间数据

多图层绘图

fig, ax = plt.subplots(figsize=(12, 6))
countries.plot(ax=ax)
cities.plot(ax=ax, color='red', markersize=10)
ax.set_axis_off()

在 Python 中处理地理空间数据

Passons à la pratique !

在 Python 中处理地理空间数据

Preparing Video For Download...