Skip to content

Commit 5b99a3b

Browse files
Antonio CarlónAntonio Carlón
Antonio Carlón
authored and
Antonio Carlón
committed
Added SAR4Deforestation script
1 parent 8364362 commit 5b99a3b

File tree

5 files changed

+82
-0
lines changed

5 files changed

+82
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## SAR for deforestation detection
2+
3+
**SAR for deforestation detection** is a script for the **Sentinel-hub EO-Browser** (https://apps.sentinel-hub.com/eo-browser) that uses the VV and VH bands of the Sentinel 1 and transforms the cartesian space of VV and VH to polar coordinates computing the length and angle of the resulting vector and also the area of the square defined by VV and VH. Then it uses the lenght of the vector as a classifier to discriminate between water, forest and soil.
4+
5+
The script paints in black the water and bare soil areas, and uses both the length and the angle to draw a scale for the forest (green) and soil (red), drawing a stronger green where more forest has been classified and a stronger red or black where more soil has been found.
6+
7+
The script only uses the VV and VH bands of the Sentinel 1, so it will identify bare soil as water (black) and is intended to be used in forest area, returning strange results when used in populated areas.
8+
9+
#### Examples
10+
11+
The images show several zones of Borneo, in areas affected by palm oil deforestation
12+
13+
![Image 1](https://github.com/antoniocarlon/SAR4Deforestation/raw/master/images/image1.png)
14+
![Image 2](https://github.com/antoniocarlon/SAR4Deforestation/raw/master/images/image2.png)
15+
![Image 3](https://github.com/antoniocarlon/SAR4Deforestation/raw/master/images/image3.png)
16+
17+
A link to explore the results in the **Sentinel-hub EO-Browser**:
18+
19+
https://apps.sentinel-hub.com/eo-browser/?lat=-3.1254&lng=113.6286&zoom=10&time=2019-11-08&preset=CUSTOM&datasource=Sentinel-1%20AWS%20(S1-AWS-IW-VVVH)&layers=VV,VH,HH&evalscript=Ly8KLy8gU0FSIGZvciBkZWZvcmVzdGF0aW9uIGRldGVjdGlvbgovLyAtLS0tLS0tLS0tLS0KLy8gMjAxOSAtIEFudG9uaW8gQ2FybG9uIFBhcmVkZXMKLy8gTGljZW5zZTogQ0MgQlkgNC4wCi8vIGh0dHBzOi8vY3Jl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CgkJdl9hbmdsZV93ZWlnaHRlZCA9IE1hdGguYXRhbih2aC92dikgLyAoTWF0aC5QSSAvIDIpOwoJfQoJbGV0IHZfbGVuX2ludmVyc2UgPSAwOwogIAlpZiAodl9sZW4gPiAwKSB7CgkJdl9sZW5faW52ZXJzZSA9IDEgLyAoSU5WRVJTRV9GQUNUT1IgKiB2X2xlbik7CiAgICB9CgogIAlpZiAodl9sZW4gPCBXQVRFUl9MSU1JVCkgewogICAgCXJldHVybiBbMF07CiAgICB9IGVsc2UgaWYgKHZfbGVuID4gRk9SRVNUX0xJTUlUKSB7CiAgICAgIAlsZXQgaW5kZXggPSBHQUlOICogdl9sZW4gLSB2X2FuZ2xlX3dlaWdodGVkOwogICAgICAgIHJldHVybiBHUkVFTl9WSVoucHJvY2VzcyhpbmRleCk7CiAgICB9IGVsc2UgewogICAgICAgIGxldCBpbmRleCA9IEdBSU4gKiB2X2xlbl9pbnZlcnNlICsgdl9hbmdsZV93ZWlnaHRlZDsKICAgICAgICByZXR1cm4gUkVEX1ZJWi5wcm9jZXNzKGluZGV4KTsKICAgIH0KfTs%3D
20+
21+
#### Author
22+
23+
Antonio Carlón Paredes
Loading
Loading
Loading
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
//
2+
// SAR for deforestation detection
3+
// ------------
4+
// 2019 - Antonio Carlon Paredes
5+
// License: CC BY 4.0
6+
// https://creativecommons.org/licenses/by/4.0/
7+
//
8+
function setup(ds) {
9+
setInputComponents([ds.VV, ds.VH]);
10+
setOutputComponentCount(3);
11+
}
12+
13+
const GAIN = 2.5;
14+
const WATER_LIMIT = 0.1;
15+
const FOREST_LIMIT = 0.2;
16+
const INVERSE_FACTOR = 25;
17+
18+
const GREEN_GRADIENT = [
19+
[1.000, 0x80F300],
20+
[0.500, 0x406600],
21+
[0.000, 0x003300]
22+
]
23+
24+
const RED_GRADIENT = [
25+
[1.000, 0xFFFFFF],
26+
[0.525, 0xFF8600],
27+
[0.300, 0xFF6E00],
28+
[0.250, 0xAE0000],
29+
[0.000, 0x000000]
30+
];
31+
32+
const GREEN_VIZ = new ColorGradientVisualizer(GREEN_GRADIENT, 0, 1);
33+
const RED_VIZ = new ColorGradientVisualizer(RED_GRADIENT, 0, 1);
34+
35+
const evaluatePixel = function (samples, scenes) {
36+
let vv = samples[0].VV;
37+
let vh = samples[0].VH;
38+
39+
let area = vv * vh;
40+
let v_len = Math.sqrt(vv * vv + vh * vh);
41+
let v_angle_weighted = 0;
42+
if (vv > 0) {
43+
v_angle_weighted = Math.atan(vh/vv) / (Math.PI / 2);
44+
}
45+
let v_len_inverse = 0;
46+
if (v_len > 0) {
47+
v_len_inverse = 1 / (INVERSE_FACTOR * v_len);
48+
}
49+
50+
if (v_len < WATER_LIMIT) {
51+
return [0];
52+
} else if (v_len > FOREST_LIMIT) {
53+
let index = GAIN * v_len - v_angle_weighted;
54+
return GREEN_VIZ.process(index);
55+
} else {
56+
let index = GAIN * v_len_inverse + v_angle_weighted;
57+
return RED_VIZ.process(index);
58+
}
59+
};

0 commit comments

Comments
 (0)