Now that the PRISM data is being released in a BIL format, I decided I should update my old post on plotting PRISM arrays. First, I tried using ndimage.imread() and matplotlib.imread(), but neither worked with the BIL format. GDAL can handle it though.
import matplotlib.pyplot as plt from osgeo import gdal prism_path = 'PRISM_tmean_30yr_normal_4kmM2_annual_bil.bil' prism_nodata = -9999 prism_ds = gdal.Open(prism_path) prism_band = prism_ds.GetRasterBand(1) prism_array = prism_band.ReadAsArray().astype(np.float32) # prism_nodata = prism_band.GetNoDataValue() prism_array[prism_array == prism_nodata] = np.nan prism_ds = None plt.imshow(prism_array, cmap='viridis') plt.show()
I really like the new Viridis colormap!