Skip to content

Commit

Permalink
Merge pull request #285 from sentinel-hub/feat/multiscript
Browse files Browse the repository at this point in the history
Added multiple scripts and example links to Copernicus Browser
  • Loading branch information
jonasViehweger authored Nov 9, 2023
2 parents 16c7bfd + de383ef commit 8d575f0
Show file tree
Hide file tree
Showing 48 changed files with 1,019 additions and 426 deletions.
5 changes: 5 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,8 @@ gh_edit_view_mode: "tree" # "tree" or "edit" if you want the user to jump into t

plugins:
- jekyll-seo-tag

callouts:
note:
title: Note
color: yellow
3 changes: 0 additions & 3 deletions _includes/js/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,5 @@
}
});
});
// Get the element with id="defaultOpen" and click on it
document.getElementById("defaultOpen").click();

});
})(window.jtd = window.jtd || {});
8 changes: 4 additions & 4 deletions _layouts/script.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ <h1 class="d-inline" id={{page.slug}}> {{page.title}} </h1>
<div class="tab", id="script">

{% for script in page.scripts %}
<button class="tablinks" onclick="openTab(event, '{{ script[0] }}')" {%- if forloop.first -%} id="defaultOpen" {%- endif -%}>{{ script[0] }}</button>
<button class="tablinks {% if forloop.first %} active {%- endif -%}" onclick="openTab(event, '{{ script[0] }}')">{{ script[0] }}</button>
{% else %}
<!-- This will be carried out by default if page.scripts is empty -->
<button class="tablinks" onclick="openTab(event, 'Evalscript')" id="defaultOpen">Evalscript</button>
<button class="tablinks active" onclick="openTab(event, 'Evalscript')">Evalscript</button>
{% endfor %}
</div>

Expand All @@ -21,13 +21,13 @@ <h1 class="d-inline" id={{page.slug}}> {{page.title}} </h1>
{% for script in page.scripts %}
{% assign file = script[1] %}
<!-- Tab content -->
<div id="{{ script[0] }}" class="tabcontent">
<div id="{{ script[0] }}" class="tabcontent" {% if forloop.first %} style="display: block;" {%- endif -%}>
{% highlight javascript %}
{% include_relative {{ file }} %}
{% endhighlight %}
</div>
{% else %}
<div id="Evalscript" class="tabcontent">
<div id="Evalscript" class="tabcontent" style="display: block;">
{% highlight javascript %}
{% include_relative script.js %}
{% endhighlight %}
Expand Down
11 changes: 8 additions & 3 deletions sentinel-1/radar_vegetation_index/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,25 @@ grand_parent: Sentinel
layout: script
permalink: /sentinel-1/radar_vegetation_index/
nav_exclude: true
scripts:
- [Visualization, script.js]
- [EO Browser, eob.js]
- [Raw Values, raw.js]
---


## Evaluate and visualize
- [EO Browser](https://apps.sentinel-hub.com/eo-browser/?lat=49.6989&lng=-98.0248&zoom=11&time=2019-06-28&preset=CUSTOM&datasource=Sentinel-1%20AWS%20(S1-AWS-IW-VVVH)&layers=VV,VH,HH&evalscript=Ly8gUmFkYXIgdmVnZXRhdGlvbiBpbmRleCBmb3IgU2VudGluZWwtMSAoUlZJNFMxKSBTQVIgZGF0YQovLyBJbnN0aXR1dGU6IE1SU0xhYiwgSW5kaWFuIEluc3RpdHV0ZSBvZiBUZWNobm9sb2d5IEJvbWJheSwgSW5kaWEKLy8gRGF0YSByZXF1aXJlbWVudHM6IFNlbnRpbmVsLTEgR1JEIGRhdGEKbGV0IGRvcCA9IChWVi8oVlYrVkgpKTsgLy9lcXVpdmFsZW50IHRvIGNvbXBsZW1lbnQgb2YgdGhlIGRlZ3JlZSBvZiBwb2xhcml6YXRpb24KbGV0IG0gPSAxIC0gZG9wOyAgCmxldCB2YWx1ZSA9IChNYXRoLnNxcnQoZG9wKSkqKCg0KihWSCkpLyhWVitWSCkpOyAgLy9kZXBvbGFyaXphdGlvbiB3aXRoaW4gdGhlIHZlZ2V0YXRpb24gCgovL3JldHVybiBbIHZhbHVlIF0gLy9HcmF5c2NhbGUgcmVzdWx0CgovLyBDb2xvdXIgc2NhbGUKcmV0dXJuIGNvbG9yQmxlbmQgLy8gY2FsbCB0aGUgY29sb3JCbGVuZCBmdW5jdGlvbgoodmFsdWUsIC8vIFBpeGVsIHZhbHVlClswLCAwLjEsIDAuMywgMC41LCAwLjcsIDAuOSwgMS4wXSwgLy8gRGVmaW5lIHRoZSBib3JkZXJzClsgWzAsIDAsIDFdLCAvLyBEZWZpbmUgdGhlIFJHQiBjb2xvcnMgZm9yIGVhY2ggYm9yZGVyClswLjEsMC4yLDAuOF0sClswLjMsIDAuNSwgMC43XSwKWzAuMiwgMSwgMC4zXSwKWzAuNSwgMC44LCAwLjJdLApbMSwgMC40LCAwXSwKWzEsIDAsIDBdLApdKTs%3D){:target="_blank"}
- [EO Browser](https://sentinelshare.page.link/cxF5){:target="_blank"}
- [Copernicus Browser](link.dataspace.copernicus.eu/v6y){:target="_blank"}


## General description of the script

The goal of the script is to calculate the Radar Vegetation Index for Sentinel-1 (RVI4S1) like dual-pol SAR data. In this script, we utilize Sentinel-1 GRD products as input and calculate the RVI4S1 index for monitoring crop growth. The theoretical value of this index ranges from 0 to 1. The bare soil or pure elementary targets indicate a very low RVI4S1 index towards zero. Conversely, a fully developed crop canopy advance the index towards 1. The index is represented with a colour scale equivalent to a jet colour map scheme. So, zero value is indicated by blue, whereas red indicates RVI4S1 ==1.0.
The goal of the script is to calculate the Radar Vegetation Index for Sentinel-1 (RVI4S1) like dual-pol SAR data. In this script, we utilize Sentinel-1 GRD products as input and calculate the RVI4S1 index for monitoring crop growth. The theoretical value of this index ranges from 0 to 1. The bare soil or pure elementary targets indicate a very low RVI4S1 index towards zero. Conversely, a fully developed crop canopy advance the index towards 1. Zero is indicated by pink, whereas green indicates RVI4S1 == 1.0.

## Details of the script

The script is applicable to monitor crop condition over the global scale and invariant to crop types. The vegetation indices developed here utilize the GRD product. First, an equivalent to the degree of polarization (DOP) is calculated as VV/SPAN. SPAN is total power received at both the channel and can be treated as VV+VH. The DOP is utilized to obtain the depolarized fraction as m = 1 ñ DOP. The m factor ranges between 0 and 1. For pure or elementary targets the m value is close to zero; whereas for fully random canopy (at high vegetative growth), it reaches close to 1. This m factor is multiplied with the vegetation depolarization power fraction (4xVH)/(VV+VH). The m factor is modulated with a square root scaling for a better dynamic range of the RVI4S1 index. The index also separates urban areas and bare soil from the vegetated terrain. However, for very rough soil (likely after tillage) or water surface (high windy condition), the DOP would be lower, which turns the RVI4S1 to be quite higher than a smooth surface. Hence care should be taken with this particular condition.
The script is applicable to monitor crop condition over the global scale and invariant to crop types. The vegetation indices developed here utilize the GRD product. First, an equivalent to the degree of polarization (DOP) is calculated as VV/SPAN. SPAN is total power received at both the channel and can be treated as VV+VH. The DOP is utilized to obtain the depolarized fraction as m = 1 - DOP. The m factor ranges between 0 and 1. For pure or elementary targets the m value is close to zero; whereas for fully random canopy (at high vegetative growth), it reaches close to 1. This m factor is multiplied with the vegetation depolarization power fraction (4xVH)/(VV+VH). The m factor is modulated with a square root scaling for a better dynamic range of the RVI4S1 index. The index also separates urban areas and bare soil from the vegetated terrain. However, for very rough soil (likely after tillage) or water surface (high windy condition), the DOP would be lower, which turns the RVI4S1 to be quite higher than a smooth surface. Hence care should be taken with this particular condition.

## Author of the script

Expand Down
41 changes: 41 additions & 0 deletions sentinel-1/radar_vegetation_index/eob.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//VERSION=3
function setup() {
return {
input: ["VV", "VH", "dataMask"],
output: [
{ id: "default", bands: 4 },
{ id: "index", bands: 1, sampleType: "FLOAT32" },
{ id: "eobrowserStats", bands: 1, sampleType: 'FLOAT32' },
{ id: "dataMask", bands: 1 }
]
};
}

const ramp = [
[0, 0x8e0152],
[0.25, 0xde77ae],
[0.5, 0xf7f7f7],
[0.75, 0x7fbc41],
[1, 0x276419],
];


const visualizer = new ColorRampVisualizer(ramp);

function evaluatePixel(samples) {
let dop = (samples.VV / (samples.VV + samples.VH));
let m = 1 - dop;
//depolarization within the vegetation
let val = (Math.sqrt(dop)) * ((4 * (samples.VH)) / (samples.VV + samples.VH));
// The library for tiffs works well only if there is only one channel returned.
// So we encode the "no data" as NaN here and ignore NaNs on frontend.
const indexVal = samples.dataMask === 1 ? val : NaN;
const imgVals = visualizer.process(val);

return {
default: imgVals.concat(samples.dataMask),
index: [indexVal],
eobrowserStats: [val],
dataMask: [samples.dataMask]
};
}
18 changes: 18 additions & 0 deletions sentinel-1/radar_vegetation_index/raw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Radar vegetation index for Sentinel-1 (RVI4S1) SAR data
// Institute: MRSLab, Indian Institute of Technology Bombay, India
// Data requirements: Sentinel-1 GRD data
function setup() {
return {
input: ["VV", "VH"],
output: { bands: 1, sampleType: "FLOAT32" }
};
}

function evaluatePixel(samples) {
//equivalent to complement of the degree of polarization
let dop = (samples.VV / (samples.VV + samples.VH));
let m = 1 - dop;
//depolarization within the vegetation
let value = (Math.sqrt(dop)) * ((4 * (samples.VH)) / (samples.VV + samples.VH));
return [value]
}
50 changes: 29 additions & 21 deletions sentinel-1/radar_vegetation_index/script.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
// Radar vegetation index for Sentinel-1 (RVI4S1) SAR data
// Institute: MRSLab, Indian Institute of Technology Bombay, India
// Data requirements: Sentinel-1 GRD data
let dop = (VV/(VV+VH)); //equivalent to complement of the degree of polarization
let m = 1 - dop;
let value = (Math.sqrt(dop))*((4*(VH))/(VV+VH)); //depolarization within the vegetation

//return [ value ] //Grayscale result

// Colour scale
return colorBlend // call the colorBlend function
(value, // Pixel value
[0, 0.1, 0.3, 0.5, 0.7, 0.9, 1.0], // Define the borders
[ [0, 0, 1], // Define the RGB colors for each border
[0.1,0.2,0.8],
[0.3, 0.5, 0.7],
[0.2, 1, 0.3],
[0.5, 0.8, 0.2],
[1, 0.4, 0],
[1, 0, 0],
]);
// Radar vegetation index for Sentinel-1 (RVI4S1) SAR data
// Institute: MRSLab, Indian Institute of Technology Bombay, India
// Data requirements: Sentinel-1 GRD data
function setup() {
return {
input: ["VV", "VH", "dataMask"],
output: { bands: 4 }
};
}

const ramp = [
[0, 0x8e0152],
[0.25, 0xde77ae],
[0.5, 0xf7f7f7],
[0.75, 0x7fbc41],
[1, 0x276419],
];

const visualizer = new ColorRampVisualizer(ramp);

function evaluatePixel(samples) {
//equivalent to complement of the degree of polarization
let dop = (samples.VV / (samples.VV + samples.VH));
let m = 1 - dop;
//depolarization within the vegetation
let value = (Math.sqrt(dop)) * ((4 * (samples.VH)) / (samples.VV + samples.VH));
let imgVals = visualizer.process(value);
return imgVals.concat(samples.dataMask)
}
16 changes: 12 additions & 4 deletions sentinel-2/evi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,23 @@ grand_parent: Sentinel
layout: script
permalink: /sentinel-2/evi/
nav_exclude: true
scripts:
- [Visualization, script.js]
- [EO Browser, eob.js]
- [Raw Values, raw.js]
---


## Evaluate and visualize
- [Sentinel Playground](https://apps.sentinel-hub.com/sentinel-playground/?source=S2&lat=42.10051506871418&lng=12.23602294921875&zoom=11&preset=CUSTOM&layers=B01,B02,B03&maxcc=20&gain=1.0&gamma=1.0&time=2019-05-01%7C2019-11-21&atmFilter=&showDates=false&evalscript=Ly8gRW5oYW5jZWQgVmVnZXRhdGlvbiBJbmRleCAgKGFiYnJ2LiBFVkkpCi8vIEdlbmVyYWwgZm9ybXVsYTogMi41ICogKE5JUiAtIFJFRCkgLyAoKE5JUiArIDYqUkVEIC0gNy41KkJMVUUpICsgMSkKLy8gVVJMIGh0dHBzOi8vd3d3LmluZGV4ZGF0YWJhc2UuZGUvZGIvc2ktc2luZ2xlLnBocD9zZW5zb3JfaWQ9OTYmcnNpbmRleF9pZD0xNgoKbGV0IEVWSSA9IDIuNSAqIChCMDggLSBCMDQpIC8gKChCMDggKyA2LjAgKiBCMDQgLSA3LjUgKiBCMDIpICsgMS4wKTsKCmlmIChFVkk8LTEuMSkgcmV0dXJuIFswLDAsMF07CmVsc2UgaWYgKEVWSTwtMC4yKSByZXR1cm4gWzAuNzUsMC43NSwxXTsKZWxzZSBpZiAoRVZJPC0wLjEpIHJldHVybiBbMC44NiwwLjg2LDAuODZdOwplbHNlIGlmIChFVkk8MCkgcmV0dXJuIFsxLDEsMC44OF07CmVsc2UgaWYgKEVWSTwwLjAyNSkgcmV0dXJuIFsxLDAuOTgsMC44XTsKZWxzZSBpZiAoRVZJPDAuMDUpIHJldHVybiBbMC45MywwLjkxLDAuNzFdOwplbHNlIGlmIChFVkk8MC4wNzUpIHJldHVybiBbMC44NywwLjg1LDAuNjFdOwplbHNlIGlmIChFVkk8MC4xKSByZXR1cm4gWzAuOCwwLjc4LDAuNTFdOwplbHNlIGlmIChFVkk8MC4xMjUpIHJldHVybiBbMC43NCwwLjcyLDAuNDJdOwplbHNlIGlmIChFVkk8MC4xNSkgcmV0dXJuIFswLjY5LDAuNzYsMC4zOF07CmVsc2UgaWYgKEVWSTwwLjE3NSkgcmV0dXJuIFswLjY0LDAuOCwwLjM1XTsKZWxzZSBpZiAoRVZJPDAuMikgcmV0dXJuIFswLjU3LDAuNzUsMC4zMl07CmVsc2UgaWYgKEVWSTwwLjI1KSByZXR1cm4gWzAuNSwwLjcsMC4yOF07CmVsc2UgaWYgKEVWSTwwLjMpIHJldHVybiBbMC40NCwwLjY0LDAuMjVdOwplbHNlIGlmIChFVkk8MC4zNSkgcmV0dXJuIFswLjM4LDAuNTksMC4yMV07CmVsc2UgaWYgKEVWSTwwLjQpIHJldHVybiBbMC4zMSwwLjU0LDAuMThdOwplbHNlIGlmIChFVkk8MC40NSkgcmV0dXJuIFswLjI1LDAuNDksMC4xNF07CmVsc2UgaWYgKEVWSTwwLjUpIHJldHVybiBbMC4xOSwwLjQzLDAuMTFdOwplbHNlIGlmIChFVkk8MC41NSkgcmV0dXJuIFswLjEzLDAuMzgsMC4wN107CmVsc2UgaWYgKEVWSTwwLjYpIHJldHVybiBbMC4wNiwwLjMzLDAuMDRdOwplbHNlIHJldHVybiBbMCwwLjI3LDBdOw%3D%3D){:target="_blank"}
- [EO Browser](https://apps.sentinel-hub.com/eo-browser/?lat=42.3388&lng=11.9971&zoom=10&time=2017-10-08&preset=CUSTOM&datasource=Sentinel-2%20L1C&layers=B01,B02,B03&evalscript=Ly8gRW5oYW5jZWQgVmVnZXRhdGlvbiBJbmRleCAgKGFiYnJ2LiBFVkkpCi8vIEdlbmVyYWwgZm9ybXVsYTogMi41ICogKE5JUiAtIFJFRCkgLyAoKE5JUiArIDYqUkVEIC0gNy41KkJMVUUpICsgMSkKLy8gVVJMIGh0dHBzOi8vd3d3LmluZGV4ZGF0YWJhc2UuZGUvZGIvc2ktc2luZ2xlLnBocD9zZW5zb3JfaWQ9OTYmcnNpbmRleF9pZD0xNgoKbGV0IEVWSSA9IDIuNSAqIChCMDggLSBCMDQpIC8gKChCMDggKyA2LjAgKiBCMDQgLSA3LjUgKiBCMDIpICsgMS4wKTsKCmlmIChFVkk8LTEuMSkgcmV0dXJuIFswLDAsMF07CmVsc2UgaWYgKEVWSTwtMC4yKSByZXR1cm4gWzAuNzUsMC43NSwxXTsKZWxzZSBpZiAoRVZJPC0wLjEpIHJldHVybiBbMC44NiwwLjg2LDAuODZdOwplbHNlIGlmIChFVkk8MCkgcmV0dXJuIFsxLDEsMC44OF07CmVsc2UgaWYgKEVWSTwwLjAyNSkgcmV0dXJuIFsxLDAuOTgsMC44XTsKZWxzZSBpZiAoRVZJPDAuMDUpIHJldHVybiBbMC45MywwLjkxLDAuNzFdOwplbHNlIGlmIChFVkk8MC4wNzUpIHJldHVybiBbMC44NywwLjg1LDAuNjFdOwplbHNlIGlmIChFVkk8MC4xKSByZXR1cm4gWzAuOCwwLjc4LDAuNTFdOwplbHNlIGlmIChFVkk8MC4xMjUpIHJldHVybiBbMC43NCwwLjcyLDAuNDJdOwplbHNlIGlmIChFVkk8MC4xNSkgcmV0dXJuIFswLjY5LDAuNzYsMC4zOF07CmVsc2UgaWYgKEVWSTwwLjE3NSkgcmV0dXJuIFswLjY0LDAuOCwwLjM1XTsKZWxzZSBpZiAoRVZJPDAuMikgcmV0dXJuIFswLjU3LDAuNzUsMC4zMl07CmVsc2UgaWYgKEVWSTwwLjI1KSByZXR1cm4gWzAuNSwwLjcsMC4yOF07CmVsc2UgaWYgKEVWSTwwLjMpIHJldHVybiBbMC40NCwwLjY0LDAuMjVdOwplbHNlIGlmIChFVkk8MC4zNSkgcmV0dXJuIFswLjM4LDAuNTksMC4yMV07CmVsc2UgaWYgKEVWSTwwLjQpIHJldHVybiBbMC4zMSwwLjU0LDAuMThdOwplbHNlIGlmIChFVkk8MC40NSkgcmV0dXJuIFswLjI1LDAuNDksMC4xNF07CmVsc2UgaWYgKEVWSTwwLjUpIHJldHVybiBbMC4xOSwwLjQzLDAuMTFdOwplbHNlIGlmIChFVkk8MC41NSkgcmV0dXJuIFswLjEzLDAuMzgsMC4wN107CmVsc2UgaWYgKEVWSTwwLjYpIHJldHVybiBbMC4wNiwwLjMzLDAuMDRdOwplbHNlIHJldHVybiBbMCwwLjI3LDBdOw%3D%3D){:target="_blank"}

- [EO Browser](https://sentinelshare.page.link/NnPE){:target="_blank"}
- [Copernicus Browser](https://link.dataspace.copernicus.eu/kkf){:target="_blank"}

## General description of the script

For Sentinel-2, the index looks like this:

$$EVI = 2.5 \cdot (\frac{B8-B4}{B8+6 \cdot B6-7.5 \cdot B2} + 1)$$

In areas of dense canopy cover, where leaf area index (LAI) is high, the blue wavelengths can be used to improve the accuracy of NDVI, as it corrects for soil background signals and atmospheric influences.

Values description: The range of values for EVI is -1 to 1, with healthy vegetation generally around 0.20 to 0.80.
Expand All @@ -23,4 +31,4 @@ Values description: The range of values for EVI is -1 to 1, with healthy vegetat

EVI, Italy. Acquired on 08.10.2017, processed by Sentinel Hub.

![EVI](fig/fig1.png)
![EVI](fig/fig1.png)
59 changes: 59 additions & 0 deletions sentinel-2/evi/eob.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//VERSION=3
function setup() {
return {
input: ["B02", "B03", "B04", "B08", "dataMask"],
output: [
{ id: "default", bands: 4 },
{ id: "index", bands: 1, sampleType: "FLOAT32" },
{ id: "eobrowserStats", bands: 2, sampleType: 'FLOAT32' },
{ id: "dataMask", bands: 1 }
]
};
}

const ramp = [
[-0.5, 0x0c0c0c],
[-0.2, 0xbfbfbf],
[-0.1, 0xdbdbdb],
[0, 0xeaeaea],
[0.025, 0xfff9cc],
[0.05, 0xede8b5],
[0.075, 0xddd89b],
[0.1, 0xccc682],
[0.125, 0xbcb76b],
[0.15, 0xafc160],
[0.175, 0xa3cc59],
[0.2, 0x91bf51],
[0.25, 0x7fb247],
[0.3, 0x70a33f],
[0.35, 0x609635],
[0.4, 0x4f892d],
[0.45, 0x3f7c23],
[0.5, 0x306d1c],
[0.55, 0x216011],
[0.6, 0x0f540a],
[1, 0x004400],
];

const visualizer = new ColorRampVisualizer(ramp);

function evaluatePixel(samples) {
let val = 2.5 * (samples.B08 - samples.B04) / ((samples.B08 + 6.0 * samples.B04 - 7.5 * samples.B02) + 1.0);
// The library for tiffs works well only if there is only one channel returned.
// So we encode the "no data" as NaN here and ignore NaNs on frontend.
const indexVal = samples.dataMask === 1 ? val : NaN;
const imgVals = visualizer.process(val);

return {
default: imgVals.concat(samples.dataMask),
index: [indexVal],
eobrowserStats: [val, isCloud(samples) ? 1 : 0],
dataMask: [samples.dataMask]
};
}

function isCloud(samples) {
const NGDR = index(samples.B03, samples.B04);
const bRatio = (samples.B03 - 0.175) / (0.39 - 0.175);
return bRatio > 1 || (bRatio > 0 && NGDR > 0);
}
14 changes: 14 additions & 0 deletions sentinel-2/evi/raw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//VERSION=3
function setup() {
return {
input: ["B02", "B04", "B08"],
output: {
bands: 1,
sampleType: "FLOAT32"
}
};
}

function evaluatePixel(samples) {
return [2.5 * (samples.B08 - samples.B04) / ((samples.B08 + 6.0 * samples.B04 - 7.5 * samples.B02) + 1.0)]
}
59 changes: 37 additions & 22 deletions sentinel-2/evi/script.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,42 @@
//VERSION=3
// Enhanced Vegetation Index (abbrv. EVI)
// General formula: 2.5 * (NIR - RED) / ((NIR + 6*RED - 7.5*BLUE) + 1)
// URL https://www.indexdatabase.de/db/si-single.php?sensor_id=96&rsindex_id=16
function setup() {
return {
input: ["B02", "B04", "B08", "dataMask"],
output: { bands: 4 }
};
}

let EVI = 2.5 * (B08 - B04) / ((B08 + 6.0 * B04 - 7.5 * B02) + 1.0);
const ramp = [
[-0.5, 0x0c0c0c],
[-0.2, 0xbfbfbf],
[-0.1, 0xdbdbdb],
[0, 0xeaeaea],
[0.025, 0xfff9cc],
[0.05, 0xede8b5],
[0.075, 0xddd89b],
[0.1, 0xccc682],
[0.125, 0xbcb76b],
[0.15, 0xafc160],
[0.175, 0xa3cc59],
[0.2, 0x91bf51],
[0.25, 0x7fb247],
[0.3, 0x70a33f],
[0.35, 0x609635],
[0.4, 0x4f892d],
[0.45, 0x3f7c23],
[0.5, 0x306d1c],
[0.55, 0x216011],
[0.6, 0x0f540a],
[1, 0x004400],
];

if (EVI<-1.1) return [0,0,0];
else if (EVI<-0.2) return [0.75,0.75,0.75];
else if (EVI<-0.1) return [0.86,0.86,0.86];
else if (EVI<0) return [1,1,0.88];
else if (EVI<0.025) return [1,0.98,0.8];
else if (EVI<0.05) return [0.93,0.91,0.71];
else if (EVI<0.075) return [0.87,0.85,0.61];
else if (EVI<0.1) return [0.8,0.78,0.51];
else if (EVI<0.125) return [0.74,0.72,0.42];
else if (EVI<0.15) return [0.69,0.76,0.38];
else if (EVI<0.175) return [0.64,0.8,0.35];
else if (EVI<0.2) return [0.57,0.75,0.32];
else if (EVI<0.25) return [0.5,0.7,0.28];
else if (EVI<0.3) return [0.44,0.64,0.25];
else if (EVI<0.35) return [0.38,0.59,0.21];
else if (EVI<0.4) return [0.31,0.54,0.18];
else if (EVI<0.45) return [0.25,0.49,0.14];
else if (EVI<0.5) return [0.19,0.43,0.11];
else if (EVI<0.55) return [0.13,0.38,0.07];
else if (EVI<0.6) return [0.06,0.33,0.04];
else return [0,0.27,0];
const visualizer = new ColorRampVisualizer(ramp);

function evaluatePixel(samples) {
let evi = 2.5 * (samples.B08 - samples.B04) / ((samples.B08 + 6.0 * samples.B04 - 7.5 * samples.B02) + 1.0);
let imgVals = visualizer.process(evi);
return imgVals.concat(samples.dataMask)
}
Loading

0 comments on commit 8d575f0

Please sign in to comment.