cartopy:如何在地图顶部添加图像 [英] cartopy: how to add an image on top of map

查看:112
本文介绍了cartopy:如何在地图顶部添加图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在自定义地图上叠加自定义图像?

How to overlay a custom image on top of a cartopy map?

如果我这样做

ax = plt.axes(projection=map_quest_aerial.crs)
ax.set_extent([lon_0, lon_1, lat_0, lat_1])
plt.imshow('myimage.png', extent=(x0,x1,y0,y1))
plt.show()

我的图像在轴上正确显示.但是,如果我尝试添加背景地图图像,那么我的图像将不再显示:

my image shows up correctly in the axes. But, if I try to add the background map image, my image no longer appears:

ax = plt.axes(projection=map_quest_aerial.crs)
ax.set_extent([lon_0, lon_1, lat_0, lat_1])
ax.add_image(map_quest_aerial, 10)
plt.imshow('myimage.png', extent=(x0,x1,y0,y1))
plt.show()

仅生成地图图像.

这是不是因为地图图像真的只是一个工厂,它只在绘制命令时生成地图图像,从而破坏了我的图像?

Is this because the map image is really just a factory that generates the map image only at the draw command and thus clobbers my image?

推荐答案

这听起来像是绘图顺序的问题.我认为您需要在调用 imshow 时设置 zorder 参数,尝试使用较大的数字使图像绘制在背景之上:

This sounds like a problem with the order of drawing. I think you need to set the zorder parameter in your call to imshow, try using a large number to get the image to draw on top of the background:

plt.imshow('myimage.png', extent=(x0, x1, y0, y1), zorder=10)

这篇关于cartopy:如何在地图顶部添加图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆