Skip to content

Commit 8f3f6f0

Browse files
Merge pull request #290 from ajgeers/planet/soil-water-content
Add Soil Water Content and Land Surface Temperature scripts
2 parents 63148dd + 2480aa2 commit 8f3f6f0

File tree

6 files changed

+217
-0
lines changed

6 files changed

+217
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
title: Land Surface Temperature
3+
parent: Planetary Variables
4+
layout: script
5+
permalink: /planetary-variables/land-surface-temperature/
6+
nav_exclude: false
7+
---
8+
9+
## Evaluate and visualize
10+
As Land Surface Temperature is commercial data, brought into Sentinel Hub as Bring Your Own Data, direct EO Browser and Sentinel Playground links are not possible due to the personalized data credentials.
11+
12+
## General description
13+
Land Surface Temperature (LST) is the thermodynamic temperature of Earth’s surface. LST is a key variable controlling energy, and water fluxes over the land surface and atmosphere interface. In view of increasing extreme temperature events and a growing population exposed to these events, LST is increasingly relevant to sustainably manage food and water systems and urban living conditions.
14+
15+
Planet's LST product provides near real-time measurements twice a day at 1:30 and 13:30 solar local time and at spatial resolutions of 100 m and 1000 m. It is unhindered by clouds and has a long and consistent data record of more than 20 years. Please check [here](https://docs.sentinel-hub.com/api/latest/data/planet/land-surface-temp/#available-bands) for a list of available bands.
16+
17+
This script provides 4 outputs. The `default` output is for visualizing LST in EO Browser. The `index` output is the actual value of the LST. The `eobrowserStats` and `dataMask` outputs are configured to activate the statistical features in EO Browser.
18+
19+
## Description of representative images
20+
Land Surface Temperature (100 m) on Oct 8, 2023 at 13:30 near Hanover, Germany.
21+
22+
![Land Surface Temperature example](fig/lst.jpg)
23+
24+
## References
25+
- [Product specifications](https://planet.widen.net/s/tltwk6hnps)
26+
- [Data sheet](https://planet.widen.net/s/ttvp2rvwzd)
27+
- [Sentinel Hub documentation about Land Surface Temperature](https://docs.sentinel-hub.com/api/latest/data/planet/land-surface-temp/)
Loading
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
//VERSION=3
2+
3+
// Set defaultVis to false to scaled and choose color_min and color_max values.
4+
// LST has two observations per days: 1h30 and 13h30 solar local time
5+
6+
const defaultVis = true // true or false
7+
const color_min = 290 // default min: 263
8+
const color_max = 330 // default max: 340
9+
const sensing_time = "0130" // "0130" or "1330" or ""
10+
const variable = "LST" // LST or LST_MaskedPixels
11+
12+
//set the data for map and timeserie
13+
function setup() {
14+
return {
15+
input: [variable, "dataMask"],
16+
output: [{ id: "default", bands: 4 },
17+
{ id: "index", bands: 1, sampleType: 'FLOAT32' },
18+
{ id: "eobrowserStats", bands: 1, sampleType: 'FLOAT32' },
19+
{ id: "dataMask", bands: 1 }],
20+
mosaicking: "TILE"
21+
};
22+
}
23+
24+
//Select files based on sensing time (0130 or 1330)
25+
function preProcessScenes(collections) {
26+
collections.scenes.tiles = collections.scenes.tiles.filter(function (tile) {
27+
return tile.dataPath.includes("T" + sensing_time);
28+
})
29+
collections.scenes.tiles.sort((a, b) => new Date(b.date) - new Date(a.date));
30+
return collections
31+
}
32+
33+
//Create color ramp 250 - 340 (full range)
34+
const cmap = [
35+
[263, 0x000004],
36+
[266, 0x06051a],
37+
[270, 0x140e36],
38+
[274, 0x251255],
39+
[278, 0x3b0f70],
40+
[282, 0x51127c],
41+
[286, 0x641a80],
42+
[289, 0x782281],
43+
[293, 0x8c2981],
44+
[297, 0xa1307e],
45+
[301, 0xb73779],
46+
[305, 0xca3e72],
47+
[309, 0xde4968],
48+
[313, 0xed5a5f],
49+
[316, 0xf7705c],
50+
[320, 0xfc8961],
51+
[324, 0xfe9f6d],
52+
[328, 0xfeb77e],
53+
[332, 0xfecf92],
54+
[336, 0xfde7a9],
55+
[340, 0xfcfdbf],
56+
];
57+
58+
//updated color ramp based on color_min and color_max
59+
function updateCMap(min, max) {
60+
const numIntervals = cmap.length
61+
const intervalLength = (max - min) / (numIntervals - 1);
62+
for (let i = 0; i < numIntervals; i++) {
63+
cmap[i][0] = min + intervalLength * i
64+
}
65+
}
66+
67+
// update the min max of color bar if defaultVis set to false
68+
if (!defaultVis) updateCMap(color_min, color_max);
69+
70+
//initialize the ColorRamp
71+
const visualizer = new ColorRampVisualizer(cmap);
72+
73+
function evaluatePixel(samples) {
74+
// LST scale factor
75+
const scaleFactor = 100;
76+
const datamask = samples[0].dataMask;
77+
78+
// Precompute an array to contain observations
79+
var n_observations = samples.length;
80+
let array = new Array(n_observations).fill(0);
81+
82+
// Fill the array with values
83+
samples.forEach((sample, index) => {
84+
array[index] = samples[index][variable] / scaleFactor;
85+
});
86+
87+
// Get variable and apply scale factor
88+
for (var i = 0; i < samples.length; i++) {
89+
indexVal = samples[i][variable] / scaleFactor;
90+
}
91+
92+
// Display
93+
let imgVals = visualizer.process(indexVal);
94+
return {
95+
default: [...imgVals, datamask],
96+
index: [array],
97+
eobrowserStats: [indexVal, datamask],
98+
dataMask: [datamask]
99+
};
100+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
title: Soil Water Content
3+
parent: Planetary Variables
4+
layout: script
5+
permalink: /planetary-variables/soil-water-content/
6+
nav_exclude: false
7+
---
8+
9+
## Evaluate and visualize
10+
As Soil Water Content is commercial data, brought into Sentinel Hub as Bring Your Own Data, direct EO Browser and Sentinel Playground links are not possible due to the personalized data credentials.
11+
12+
## General description
13+
Soil Water Content (SWC) measures the amount of water in a unit volume of soil, which is crucial information for drought monitoring, water management, and climate risk assessment.
14+
15+
Planet's SWC product provides near-daily measurements at spatial resolutions of 100 m and 1000 m. It is unhindered by clouds and has a long and consistent data record of more than 20 years. Please check [here](https://docs.sentinel-hub.com/api/latest/data/planet/soil-water-content/#available-bands) for a list of available bands.
16+
17+
This script provides 4 outputs. The `default` output is for visualizing SWC in EO Browser. The `index` output is the actual value of the SWC. The `eobrowserStats` and `dataMask` outputs are configured to activate the statistical features in EO Browser.
18+
19+
## Description of representative images
20+
Soil Water Content (L band 100 m) on Sep 30th, 2023 near Hanover, Germany.
21+
22+
![Soil Water Content example](fig/swc.jpg)
23+
24+
## References
25+
- [Product specifications](https://planet.widen.net/s/5xtzljjwgg)
26+
- [Data sheet](https://planet.widen.net/s/cv7bfjhhd5)
27+
- [Sentinel Hub documentation about Soil Water Content](https://docs.sentinel-hub.com/api/latest/data/planet/soil-water-content/)
Loading
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
//VERSION=3
2+
const vmin = 0
3+
const vmax = 0.4
4+
5+
function setup() {
6+
return {
7+
input: ["SWC", "dataMask"],
8+
output: [
9+
{ id: "default", bands: 4 },
10+
{ id: "index", bands: 1, sampleType: 'FLOAT32' },
11+
{ id: "eobrowserStats", bands: 1, sampleType: 'FLOAT32' },
12+
{ id: "dataMask", bands: 1 }
13+
]
14+
};
15+
}
16+
17+
function updateColormap(vmin, vmax) {
18+
const numIntervals = cmap.length
19+
const intervalLength = (vmax - vmin) / (numIntervals - 1);
20+
for (let i = 0; i < numIntervals; i++) {
21+
cmap[i][0] = vmin + intervalLength * i
22+
}
23+
}
24+
25+
const cmap = [
26+
[0.00, 0xfff7ea],
27+
[0.05, 0xfaedda],
28+
[0.10, 0xede4cb],
29+
[0.15, 0xdedcbd],
30+
[0.20, 0xced3af],
31+
[0.25, 0xbdcba3],
32+
[0.30, 0xaac398],
33+
[0.35, 0x96bc90],
34+
[0.40, 0x80b48a],
35+
[0.45, 0x68ac86],
36+
[0.50, 0x4da484],
37+
[0.55, 0x269c83],
38+
[0.60, 0x009383],
39+
[0.65, 0x008a85],
40+
[0.70, 0x008186],
41+
[0.75, 0x007788],
42+
[0.80, 0x006d8a],
43+
[0.85, 0x00618c],
44+
[0.90, 0x00558d],
45+
[0.95, 0x00478f],
46+
[1.00, 0x003492],
47+
];
48+
49+
updateColormap(vmin, vmax);
50+
const visualizer = new ColorRampVisualizer(cmap);
51+
52+
function evaluatePixel(sample) {
53+
let scaleFactor = 1000
54+
let val = sample.SWC / scaleFactor;
55+
56+
let imgVals = visualizer.process(val);
57+
return {
58+
default: [...imgVals, sample.dataMask],
59+
index: [val],
60+
eobrowserStats: [val],
61+
dataMask: [sample.dataMask]
62+
};
63+
}

0 commit comments

Comments
 (0)