georaster-layer-for-leaflet: I don't understand how pixelValuesToColorFn works
Hi, thanks a lot for your work!
I’m new to JS and not sure how to properly use the GeoRasterLayer’s pixelValuesToColorFn option.
I want to display transparent zones where the values equal -99.0 in my GeoTIFF file, else the original color.
I wrote that:
pixelValuesToColorFn: values => values[0] === -99.0 ? null : '#000000",
But obviously everything is black where the value !== 99.0.
Could someone give me some hints?
About this issue
- Original URL
- State: open
- Created 5 years ago
- Comments: 21 (10 by maintainers)
The NoData Value for the raster is -32767. Is this SRTM / elevation data? I this case, you actually want to change your pixelValuesToColorFn to use
-32767
and not-99
.Additionally, and this is the most important part, your raster is only 1 band. It holds elevation values not color. Although GeoTIFF files are technically “image” files, they sometimes hold values and not colors. Your job will be in deciding how you want to translate an elevation value (height of 10m) into a color.
georaster-layer-for-leaflet scales things by default linearly between black and white, but it’s not pretty.
I have a greyscale single band tiff, and following the example of @khannurien above I get the following. Can anyone advise on a method or mapping for greyscale?
Awesome @draro . Looks great!
Hi @DanielJDufour sorry for the delay in my answer. you are right, GDAL was not able to understand the original Projection (Mercator 1SP) and created GTiff with wrong information. After a long headache on this i was able to manage it and the plugin worked perfectly. Thanks anyway for your time and dedication.
Here the results:
Just wanted to let you know I saw this. I’ll get back to you within 24 hrs with an answer. Thanks! 😃