【发布时间】:2020-06-24 03:16:17
【问题描述】:
如何在cartopy地图上方叠加矢量标注图像?
import cartopy.io.img_tiles as cimgt
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
class TDT(cmigt.GoogleWTS):
def _image_url(self, tile):
x, y, z = tile
url = 'http://t1.tianditu.gov.cn/DataServer?T=vec_w&x=%s&y=%s&l=%s&tk=%s' % (x, y, z, mykey)
return url
class TDT_1(cmigt.GoogleWTS):
def _image_url(self, tile):
x, y, z = tile
url = 'http://t1.tianditu.gov.cn/DataServer?T=cva_w&x=%s&y=%s&l=%s&tk=%s' % (x, y, z, mykey)
return url
def make_map(projection=ccrs.PlateCarree()):
fig, ax = plt.subplots(figsize=(9, 13),subplot_kw=dict(projection=projection))
gl = ax.gridlines(draw_labels=True)
gl.xlabels_top = gl.ylabels_right = False
gl.xformatter = LONGITUDE_FORMATTER
gl.yformatter = LATITUDE_FORMATTER
return fig, ax
extent = [105, 106, 35.5, 36.5]
request = TDT()
request_1=TDT_1()
fig, ax = make_map(projection=request.crs)
ax.set_extent(extent)
ax.add_image(request, 10)
ax.add_image(request_1, 10) #Can't to add another image,how to let it to display on the top of the map.
plt.show()
我想得到带有矢量注释的合并图像,但我只得到一张图像。 我该怎么办?
【问题讨论】:
-
在第二张图片上使用
alpha选项。试试这个ax.add_image(request_1, 10, alpha=0.5)。 -
你如何定义
merged image。举个例子很有帮助。