Data
the .tif data DEM was the altitude value represent the hypsography of one administrative division. I upload it here
The area besides the division I don't want to show them on the plot.
My aim
Plotting the hypsography of this division using plt.pcolormesh
(PS: I found out with reading .tif, plt.imshow()
was way faster than pcolormesh
. And I don't know Why).
Here I show one example which I clipped from internet.
http://7xrn7f.com1.z0.glb.clouddn.com/16-3-10/56951530.jpg
My attempt
### Using GDAL to read the .tif data
from osgeo import gdal
### Read the .tif
pathToRaster = r'./dem.tif'
raster = gdal.Open(pathToRaster, gdal.GA_ReadOnly)
dem = raster.GetRasterBand(1).ReadAsArray()
dem = dem[::-1]
### Mask the outside value
dem_mask = np.ma.masked_less(dem,0)
plt.pcolormesh(dem_mask,cmap =plt.cm.terrain)
Result
http://7xrn7f.com1.z0.glb.clouddn.com/16-3-10/45669007.jpg
Problem
In my research division, this area didn't contain the Sea/Ocean which are plotted by blue
above.
But I want to use the plt.cm.terrain
as my pcolormesh
's colormap because it fit the situation.
So, I want to remove the blue part of the colormap, and start the terrain using green
representing the plain.