Re: Convert gray band from dataset to RGB with rasterio for population density
Sean Gillies
Hi, Sorry for the slow response. On Fri, Feb 21, 2020 at 3:10 PM <acwangpython@...> wrote: https://gis.stackexchange.com/questions/351614/convert-gray-band-from-dataset-to-rgb-with-rasterio-for-population-density I downloaded a small portion of the data, GHS_POP_E2015_GLOBE_R2019A_4326_9ss_V1_0_18_4.tif, a block that covers some of the South of France and North Africa. It's the .tif file that you want to read, not the .tif.ovr file (I suspect QGIS created one for you, there are no ovr files in the downloads). The dataset has one single float64 band. To visualize it, use a matplotlib colormap with normalization. For example: import rasterio import matplotlib.pyplot as plt from matplotlib.colors import LogNorm with rasterio.open("GHS_POP_E2015_GLOBE_R2019A_4326_9ss_V1_0_18_4.tif") as dataset: data = src.read(1, masked=True) plt.imshow(data, norm=LogNorm(vmin=1e-6, vmax=data.max())) <matplotlib.image.AxesImage object at 0x12f865710> plt.show() Results in Sean Gillies
|
|