Geopandas地图分层

问题描述 投票:0回答:1

您好,亲爱的Stack社区,我正在学习使用以下代码在带有geopandas包的Spyder IDE中创建“分层”地图:

import geopandas as geopandas
import matplotlib.pyplot as plt


world = geopandas.read_file(geopandas.datasets.get_path('naturalearth_lowres'))
cities = geopandas.read_file(geopandas.datasets.get_path('naturalearth_cities'))

world.plot()

ax = plt.subplot(1, 1)
world.plot(column='pop_est', ax=ax, legend=True)

我像RStudio一样逐行执行代码。不幸的是,我只能获得一张白色的空白纸,而不是一张地图。

谢谢。

python geopandas
1个回答
0
投票

我在Jupyter上运行了示例,但我认为只要安装了软件包,它就不会更改任何内容。

f, ax = plt.subplots(1,1,figsize=(10,10))
world.plot(column='pop_est', ax=ax, legend=True)

enter image description here

如果仅对几何感兴趣,则可以执行以下操作:

world.geometry.plot(color="white", edgecolor='k')

如果将来要将此几何图形添加到地图中,则可以这样做

world.geometry.plot(color=None, edgecolor='k')
© www.soinside.com 2019 - 2024. All rights reserved.