在cartopy地图上添加具有给定坐标(lat,lon)的图像,可以通过以下步骤实现:
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
from PIL import Image
fig = plt.figure(figsize=(10, 10))
ax = plt.axes(projection=ccrs.PlateCarree())
ax.stock_img()
image_path = 'path_to_image/image.jpg'
image = Image.open(image_path)
image_size = image.size
ax.imshow(image, origin='upper', extent=[lon - image_size[0]/2, lon + image_size[0]/2, lat - image_size[1]/2, lat + image_size[1]/2], transform=ccrs.PlateCarree())
其中,lon
和lat
是给定的图像中心坐标。
ax.set_extent([lon - 2, lon + 2, lat - 2, lat + 2], crs=ccrs.PlateCarree())
ax.set_title('Image on Cartopy Map')
plt.show()
这样,就可以在cartopy地图上添加具有给定坐标(lat,lon)的图像了。
关于cartopy地图和相关产品的介绍,可以参考腾讯云地图服务(https://cloud.tencent.com/product/tianditu)提供的地图服务。
没有搜到相关的沙龙
领取专属 10元无门槛券
手把手带您无忧上云