Skip to content

Commit ae9d6bc

Browse files
committed
added ndvi with uncertainty
1 parent 91b9777 commit ae9d6bc

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

sentinel-2/ndvi_uncertainty/README.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Normalized difference vegetation index with uncertainty
2+
3+
## Evaluate and visualize
4+
- [Sentinel Playground](http://apps.sentinel-hub.com/sentinel-playground/?source=S2&lat=40.39519549132737&lng=-3.739471435546875&zoom=11&preset=CUSTOM&layers=B04,B03,B02&maxcc=20&gain=1&gamma=1&time=2015-01-01%7C2017-10-10&atmFilter=&showDates=false&evalscript=ZnVuY3Rpb24gY2xhbXAgKGEpIHsKICByZXR1cm4gYTwwID8gMCA6IGEgPiAxID8gMSA6IGE7Cn0KZnVuY3Rpb24gc2lnTkRWSSAoYjQsIHM0LCBiOCwgczgpIHsKICB2YXIgc3VtID0gYjggKyBiNDsKICB2YXIgbmR2aSA9IChiOCAtIGI0KS9zdW07CiAgdmFyIHNfbmR2aSA9IDIgLyAoc3VtKnN1bSkgKgogICAgICBNYXRoLnNxcnQoYjgqYjgqczQqczQrYjQqYjQqczgqczgpOwogIHZhciBkYXJrbmVzcyA9IGNsYW1wKDEtMipzX25kdmkpOwogIHJldHVybiBbCiAgICAwLjkqY2xhbXAoMS1uZHZpKSpkYXJrbmVzcywKICAgIDAuOCpjbGFtcChuZHZpKSpkYXJrbmVzcywKICAgIDAuMSpkYXJrbmVzc107Cn0KcmV0dXJuIHNpZ05EVkkoQjA0LCAwLjAyLCBCMDgsIDAuMDMpOw%3D%3D)
5+
- [EO Browser](http://apps.sentinel-hub.com/eo-browser/#lat=40.4167754&lng=-3.7037901999999576&zoom=10&datasource=Sentinel-2%20L1C&time=2017-10-09&preset=CUSTOM&layers=B01,B02,B03&evalscript=ZnVuY3Rpb24gY2xhbXAgKGEpIHsKICByZXR1cm4gYTwwID8gMCA6IGEgPiAxID8gMSA6IGE7Cn0KZnVuY3Rpb24gc2lnTkRWSSAoYjQsIHM0LCBiOCwgczgpIHsKICB2YXIgc3VtID0gYjggKyBiNDsKICB2YXIgbmR2aSA9IChiOCAtIGI0KS9zdW07CiAgdmFyIHNfbmR2aSA9IDIgLyAoc3VtKnN1bSkgKgogICAgICBNYXRoLnNxcnQoYjgqYjgqczQqczQrYjQqYjQqczgqczgpOwogIHZhciBkYXJrbmVzcyA9IGNsYW1wKDEtMipzX25kdmkpOwogIHJldHVybiBbCiAgICAwLjkqY2xhbXAoMS1uZHZpKSpkYXJrbmVzcywKICAgIDAuOCpjbGFtcChuZHZpKSpkYXJrbmVzcywKICAgIDAuMSpkYXJrbmVzc107Cn0KcmV0dXJuIHNpZ05EVkkoQjA0LCAwLjAyLCBCMDgsIDAuMDMpOw%3D%3D)
6+
7+
## Basic information
8+
- Bands used by the algorithm: B4, B8
9+
- Bands used by the script: B2, B3, B4, B8
10+
11+
## General description
12+
13+
The normalized difference vegetation index, abbreviated NDVI, is defined as
14+
```math
15+
NDVI := \mathtt{Index}(B8,B4) = \frac{B8-B4}{B8+B4}.
16+
```
17+
18+
The script takes uncertainty of the NDVI product into account. It is expressed in terms of uncertainties of band measurements (see [2, 3]) which are reported by ESA to be 0.02 for B4 and 0.03 for B8. The script encodes the uncertainty with darkness [2].
19+
20+
Figure below shows the color map used by the script.
21+
![Color map of the NDVI uncertainty script from [2][1]](fig/cmap.png)
22+
23+
## References
24+
[1] Wikipedia, [Normalized Difference Vegetation Index
25+
](https://en.wikipedia.org/wiki/Normalized_Difference_Vegetation_Index). Accessed on October 4th 2017.
26+
[2] Sentinel-Hub, [Ad hoc testing of algorithms globally](http://sentinel-hub.com/blog/ad-hoc-testing-algorithms-globally). Accessed October 10th 2017.
27+
[3] Wikipedia, [Propagation of uncertainty](https://en.wikipedia.org/wiki/Propagation_of_uncertainty). Accessed October 10th 2017.
37.7 KB
Loading

sentinel-2/ndvi_uncertainty/script.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
function clamp (a) {
2+
return a<0 ? 0 : a > 1 ? 1 : a;
3+
}
4+
function sigNDVI (b4, s4, b8, s8) {
5+
var sum = b8 + b4;
6+
var ndvi = (b8 - b4)/sum;
7+
var s_ndvi = 2 / (sum*sum) *
8+
Math.sqrt(b8*b8*s4*s4+b4*b4*s8*s8);
9+
var darkness = clamp(1-2*s_ndvi);
10+
return [
11+
0.9*clamp(1-ndvi)*darkness,
12+
0.8*clamp(ndvi)*darkness,
13+
0.1*darkness];
14+
}
15+
return sigNDVI(B04, 0.02, B08, 0.03);

0 commit comments

Comments
 (0)