如何使用imshow在地图上显示图像? [英] how to display a image over a map with imshow?

查看:259
本文介绍了如何使用imshow在地图上显示图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有9种不同颜色值(0-9)的geotif,并希望在地图上显示它.我正在尝试将其与matplotlib包中的底图一起使用.

I have a geotif with 9 different colour values (0-9) and want to display it over a map. I'm trying to use it with basemap from the matplotlib package.

from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt

im = plt.imread('a.tif')
extent = [-18, 52, -38, 38] # [left, right, bottom, top]
m = Basemap(projection='merc', llcrnrlon=extent[0], urcrnrlon=extent[1], llcrnrlat=extent[2], urcrnrlat=extent[3], resolution='c')
m.drawcountries() 
plt.imshow(im, extent=extent, alpha=0.6)
plt.show()

我只得到黑白图像.取消注释drawcountries()时,我会从tif中看到数据.

I only get a black and white image. When I uncomment drawcountries() I see the data from the tif.

如何在地图上绘制tif的颜色并在其中添加国家/地区边框?

How can I draw the colors of the tif on a map and add there country borders?

推荐答案

m.imshow(im, extent=extent, alpha=0.6)

这篇关于如何使用imshow在地图上显示图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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