Re: exporting single banc with a colormap to RGB.tif

Sean Gillies
 

Hi,

The library doesn't automatically convert single band color-mapped data to 3-band RGB data. You'll need to construct a new output array filled with values from the colormap and then write that to the output file. Numpy will help: make a new 2D array and replace index values with an [R, G, B] array from the colormap, then use numpy.moveaxis to turn this into a 3-band array that rasterio can write.

On Fri, Dec 6, 2019 at 7:25 PM Eyal Saiet <ejsaiet@...> wrote:
Hello,
I could not figure out how to export a single band with a colormap as an RGB.tif
A snippet of my code:
with rasterio.open(new_f_cmp,'w',**raster_cmp_p) as dst:
    dst.write(file_np_man_cs_int8.data,1)
    dst.write_colormap(1, f_dic)
    cmap=dst.colormap(1)

thanks


--


Eyal Saiet


The mind is not a vessel to be filled, but a fire to be kindled. Plutarch


--
Sean Gillies

Join main@rasterio.groups.io to automatically receive all group messages.