Re: Applying Color Ramp to Single-Band Grayscale Images


Eyal Saiet
 

Hello Sean,
I am at the same place Nathan was a few years ago, and have not seen more development in rasterio on that font. If I would like to use a coloramp like "spectrum" in the matplolib library or something similar in ArcGIS/QGIS what is the format of a file to read a coloramp (.csv,.json,.txt, etc')? Do I need to generate the color ramp myself (dininiary) for each pixel value from 0-256 (8 bit)? The example you referred, to, and the only thing I found in the Rasterio Documentation is a classified raster with only a few colors.
dst.write_colormap(
            1, {
                0: (255, 0, 0, 255),
                255: (0, 0, 255, 255) })
https://rasterio.readthedocs.io/en/latest/topics/color.html

Does Rasterio not have a coloramp library likematplotlib has (https://matplotlib.org/stable/gallery/color/colormap_reference.html)?
Thanks

On Wed, Mar 25, 2020 at 10:04 AM Sean Gillies <sean.gillies@...> wrote:
Hi,

Have you seen https://rasterio.readthedocs.io/en/latest/topics/color.html#writing-colormaps ? It shows how to write a colormap (or color "ramp") to a new file. You can also open an existing file in "r+" mode and call the dataset's write_colormap() method.

On Tue, Mar 24, 2020 at 4:12 PM <nathan.raley@...> wrote:
Does anyone have any methods of applying a color ramp to a grayscale image? 

I have a NDVI calculated image I am trying to apply color ramp for the decimal based value ranges, but have no idea how to accomplish this.  I was wandering if this was possible via any of the rasterio libraries, and, if so, how would one go about accomplishing this?  I have other band based calculations I'd like to attempt, but until I can figure out how to apply the color ramps, I am at a stand still.

Thanks,

--
Sean Gillies



--


Eyal Saiet

Project manager
Remote sensing and in-situ measurements

Geophysical Institute 
University of Alaska Fairbanks
Fairbanks, AK 99775
(907) 750 6555 (cell)



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

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