-
-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I don't understand how pixelValuesToColorFn works #16
Comments
Just wanted to let you know I saw this. I'll get back to you within 24 hrs with an answer. Thanks! :-) |
@khannurien , how many bands does your raster have? If it's a simple 3-Band RGB raster you could do: pixelValuesToColorFn: values => values[0] === -99.0 ? null : `rgb(${values[0]},${values[1]},${values[2]})` If it's a four-band RGBA raster, you could do: pixelValuesToColorFn: values => values[0] === -99.0 ? null : `rgba(${values[0]},${values[1]},${values[2]},${values[3]/255})` If it's not 3 or 4-bands, things get more complicated, but I'm happy to help. Please let me know if it works or if you have any other questions. I'd like to improve the documentation to make it more clear. Thanks!! |
First I want to be very clear that I'm not familiar neither with JS nor with TIFF/GeoTIFF. Please forgive my newbism :-) I tried both your solutions and got the same result each time: The original render is as follows: Here is the GeoTIFF file: https://file.io/J4ARZ8 Thanks for your follow-up! |
@khannurien , could you try sharing the file again? I get this error when I go to your link: Thanks |
Done, I emailed it to you! |
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 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. |
You will also want to scale your values for RGB. Elevation ranges from 2 to 634 in this image, but RGB only goes from 0 to 255. Keep me updated:-) |
In case anyone is wandering here :-) I manually scale colors:
That works, but I'd rather do some statistics on data repartition. @DanielJDufour, can I access min/max values of the raster from inside the function? |
Sorry, I haven't gotten back to you on this. I'm slammed with work at the moment. |
Hi, Thanks in advance, |
Hi, @draro . Could you describe a little more how your file is created? It seems that its CRS might be formatted incorrectly. Here is the output from gdalinfo:
It seems to be in EPSG 4326, but the pixelSize is not in degrees, which is common. |
Hi @DanielJDufour |
Awesome @draro . Looks great! |
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? |
Hi @DanielJDufour
where colorOb is an Object containing color mapping<float,hex> I am trying to understand what exactly does pixelValue contains as it does not have float values that are a part of the dataset and it makes the color mapping process difficult for intermediate values. |
Hello hope someone can help, thanks in advance. I am having issues with 3 band RGB tif, I have been only using single band, now I am trying to show 3 band but colors does not show ok all are paster like and very weird colors, the image is a satellite image converted to geotiff. Tested in my map and in http://app.geotiff.io/. tif made with GDAL_translate,and warp from jpg The tif is posted here https://nube1.on.gt/goes/georef.tif and if I open in QGIS is shows ok (https://i.imgur.com/eZHI2GK.jpg), this is the GDALINFO of TIFF |
Hello, this issue give me lots of inspiration! I hope the plugin offers some flexible color gradient, such as 'rainbow', 'viridis', 'turbo', etc. |
If you simply omit that function the colors will be chosen automatically according to a gray gradient working example here: https://jsfiddle.net/joao_pimentel/bv4z7khq/ |
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:
But obviously everything is black where the value !== 99.0.
Could someone give me some hints?
The text was updated successfully, but these errors were encountered: