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?
m.imshow(im, extent=extent, alpha=0.6)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With