I have a single band GeoTIFF image which displays correctly in QGIS. However I tried viewing the same file using matplotlib and rasterio but I get a different output. Is there something that I am doing incorrectly? How do I display it like it is in QGIS? I would also like to use a colour map for representing the different values of the single band with a color. The EPSG of the GeoTIFF is 4326.
Here's my code:
import os
import rasterio
from rasterio.plot import show
from mpl_toolkits.basemap import Basemap
from matplotlib import pyplot as plt
from osgeo import gdal
if __name__ == "__main__":
input_Dir = 'generated_46.tif'
tiff_file = input_Dir
raster = rasterio.open(tiff_file)
print(raster.crs)
bbox = raster.bounds
show(raster.read(),cmap="gray")
Here's how it appears in qgis: