Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to display a image over a map with imshow?

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()

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

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

like image 966
gustavgans Avatar asked Mar 17 '23 18:03

gustavgans


1 Answers

m.imshow(im, extent=extent, alpha=0.6)
like image 57
Kirubaharan J Avatar answered Mar 21 '23 06:03

Kirubaharan J