|
| 1 | +//VERSION=3 |
| 2 | +// Mangrove Radar Index by András Zlinszky, Sinergise Solutions |
| 3 | +// enables color palette visualization of Sentinel-1 VV backscatter |
| 4 | +// Mangrove often has a slightly higher reflectivity in Sentinel-1 VV than other vegetation. You can tune palette min and max values and individual color thresholds to find mangrove. |
| 5 | +// Note that other vegetation (eg banana plantations) and other land cover classes (eg cities) may also reflect strongly in VV, so the visualization is not selective for mangrove. |
| 6 | + |
| 7 | +// set constants for the color map minimum and maximum here. These will override the values in the colormap variable, with the individual color steps scaling proportionally to their value, within the interval set by the min and max. |
| 8 | +const max = 0.87; |
| 9 | +const min = -0.05; |
| 10 | + |
| 11 | + |
| 12 | +// adding input data bands, defining outputs |
| 13 | +function setup() { |
| 14 | + return { |
| 15 | + input: ["VV", "dataMask"], |
| 16 | + output: [ |
| 17 | + { id: "default", bands: 4 }, |
| 18 | + { id: "eobrowserStats", bands: 1 }, |
| 19 | + { id: "dataMask", bands: 1 }, |
| 20 | + { id: "index", bands: 1, sampleType: "FLOAT32" }, |
| 21 | + ], |
| 22 | + }; |
| 23 | +} |
| 24 | + |
| 25 | +//defining the color map https://documentation.dataspace.copernicus.eu/APIs/SentinelHub/Evalscript/Functions.html#colormapvisualizer |
| 26 | + |
| 27 | +const map = [ |
| 28 | + [0.9, 0xf7eafd], //very light lavender |
| 29 | + [0.73, 0xebebeb], //very light grey |
| 30 | + [0.7, 0xa76b18], //brown ochre |
| 31 | + [0.65, 0xdca620], //golden yellow |
| 32 | + [0.6, 0xA2AE32], //olive green |
| 33 | + [0.4, 0x18a722], //bright green |
| 34 | + [0.3, 0x018643], //deep green |
| 35 | + [0.2, 0x15965], //teal green |
| 36 | + [0.1, 0x01471c], //very dark green |
| 37 | + [0.075, 0x0d5854], //dark turquoise |
| 38 | + [0.05, 0x7102c], //blue |
| 39 | + [0.04, 0x0d027e], //dark blue |
| 40 | + [0.01, 0x08014c], //very dark blue |
| 41 | + [0.005, 0x4a4a4a], //dark grey |
| 42 | +]; |
| 43 | + |
| 44 | +const visualizer = new ColorRampVisualizer(map, min, max); |
| 45 | + |
| 46 | +function evaluatePixel(samples) { |
| 47 | + const value = Math.max(0, Math.log(samples.VV) * 0.21714724095 + 1); |
| 48 | + const imgVals = visualizer.process(value) |
| 49 | + return { |
| 50 | + default: [...imgVals, samples.dataMask], |
| 51 | + eobrowserStats: [value], |
| 52 | + dataMask: [samples.dataMask], |
| 53 | + index: [value], |
| 54 | + }; |
| 55 | +} |
| 56 | +// This section is copied from the regular Sentinel-1 mosaics VV decibel gamma evalscript |
| 57 | +// --- |
| 58 | +/* |
| 59 | + // displays VV in decibels from -20 to 0 |
| 60 | + // the following is simplified below |
| 61 | + // var log = 10 * Math.log(VV) / Math.LN10; |
| 62 | + // var val = Math.max(0, (log + 20) / 20); |
| 63 | + |
| 64 | + return [Math.max(0, Math.log(VV) * 0.21714724095 + 1)]; |
| 65 | +*/ |
0 commit comments