How to get NDVI index value of the pixel

so I am using WMSLayer and I have successful placed my clipped image on the map but I want a situation where when I hover most preferred or on click I get the ndvi, ndwi or savi value of image layer

Here is my evalscript that I am using in my OGC.

//This script was converted from v1 to v3 using the converter API

if (dataMask == 0) return [0,0,0,0];

var val = (B08-B04)/(B08+B04);

return colorBlend(val, [-0.2, 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0 ],
[[0, 0, 0], // < -.2 = #000000 (black)
[165/255,0,38/255,1], // → 0 = #a50026
[215/255,48/255,39/255,1], // → .1 = #d73027
[244/255,109/255,67/255,1], // → .2 = #f46d43
[253/255,174/255,97/255,1], // → .3 = #fdae61
[254/255,224/255,139/255,1], // → .4 = #fee08b
[255/255,255/255,191/255,1], // → .5 = #ffffbf
[217/255,239/255,139/255,1], // → .6 = #d9ef8b
[166/255,217/255,106/255,1], // → .7 = #a6d96a
[102/255,189/255,99/255,1], // → .8 = #66bd63
[26/255,152/255,80/255,1], // → .9 = #1a9850
[0,104/255,55/255,1] // → 1.0 = #006837

please I am new to this and I will appreciate a detailed walk down of the process please

here is the end image that i want:
Thank you :hugs:


you can try achieving getting the value on hover with the leaflet-tilelayer-colorpicker. But note that this leaflet extension gets the display value (color) from the data on the map, not the raw value.
Some additional links:

The easiest way of getting the raw value is unfortunately not really usable with hovering, because it would constantly request data for new positions from Sentinel Hub.
But it can be done with leaflet markers (examples of leaflet markers in leaflet tutorials).
After the user places the marker, you can get the position, make a request to Sentinel Hub to get the raw data (not the colors for visualization) for the bounding box of that position and display it somewhere (maybe even as a tooltip of the marker).

Unfortunately I don’t have any simple working example at hand, but letting users place markers on the map is fairly easy and getting the data can be done in one of the event handler functions for markers.

Hope this helps. Your insights and assistance have been incredibly helpful to me. I truly appreciate your willingness to provide guidance and support.

Thank you so much for your contribution.

Best regards,

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.