我试图在绘图后添加一个真实的地图,以显示数据点的位置
但我不知道如何添加真正的地图
我试过几种方法,比如在情节后面放另一个png
但这是不对的
这是我得到的
import geopandas as gpd
import tilemapbase
BBox = (df.Longitude.min(), df.Longitude.max(), df.Latitude.min(), df.Latitude.max())
print(BBox)
(3.3990449, 7.042425700000001, 50.8134557, 53.4066264)
tilemapbase.start_logging()
tilemapbase.init(create=True)
extent = tilemapbase.extent_from_frame(NL_shape, buffer = 25)
fig, ax = plt.subplots(figsize=(10,10))
plotter = tilemapbase.Plotter(extent, tilemapbase.tiles.build_OSM(), width=1000)
plotter.plot(ax)
ax.set_xlim(BBox[0]-0.2, BBox[1]+0.2)
ax.set_ylim(BBox[2]-0.5, BBox[3]+0.5)
NL_shape.plot(ax=ax, alpha=0.3, edgecolor="black", facecolor="white")
stores_shape.plot(ax=ax, alpha = 0.2, color="red", marker='o');
我按照这里的指示:https://rosenfelder.ai/create-maps-with-python/
我使用geopandas读取国家边界(json),然后绘制数据
但是我不能使用tilemapbase下载realmap
结果如下:
有人知道如何解决这个问题吗?多谢各位
预期的图像如下所示。基本地图应该像OpenStreetmap一样
在我使用上下文后,我出现了一个错误
它显示如下:
使用为GeoPandas制作的
contextily
库。-https://contextily.readthedocs.io/en/latest/相关问题 更多 >
编程相关推荐