Skip to content

Commit 58a27f2

Browse files
Updated script to be in line with EOB, added note about how to access different times in the day
1 parent d0d7a3e commit 58a27f2

File tree

2 files changed

+26
-32
lines changed
  • planetary-variables/land-surface-temperature/land-surface-temperature-visualization

2 files changed

+26
-32
lines changed

planetary-variables/land-surface-temperature/land-surface-temperature-visualization/eob.js

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@
77
// LST has two observations per days: 1h30 and 13h30 solar local time
88

99
const defaultVis = true; // true or false
10-
const color_min = 290; // default min: 263
11-
const color_max = 330; // default max: 340
12-
const sensing_time = "0130"; // "0130" or "1330" or ""
13-
const variable = "LST"; // LST or LST_MaskedPixels
10+
const color_min = 263; // default min: 263
11+
const color_max = 340; // default max: 340
12+
const sensing_time = "1330"; // "0130" or "1330" or ""
1413

1514
//set the data for map and timeserie
1615
function setup() {
1716
return {
18-
input: [variable, "dataMask"],
17+
input: ["LST", "dataMask"],
1918
output: [
2019
{ id: "default", bands: 4 },
2120
{ id: "index", bands: 1, sampleType: "FLOAT32" },
@@ -31,13 +30,10 @@ function preProcessScenes(collections) {
3130
collections.scenes.tiles = collections.scenes.tiles.filter(function (tile) {
3231
return tile.dataPath.includes("T" + sensing_time);
3332
});
34-
collections.scenes.tiles.sort(
35-
(a, b) => new Date(b.date) - new Date(a.date)
36-
);
3733
return collections;
3834
}
3935

40-
//Create color ramp 250 - 340 (full range)
36+
//Create color ramp 263 - 340 (full range)
4137
const cmap = [
4238
[263, 0x000004],
4339
[266, 0x06051a],
@@ -80,28 +76,22 @@ const visualizer = new ColorRampVisualizer(cmap);
8076
function evaluatePixel(samples) {
8177
// LST scale factor
8278
const scaleFactor = 100;
83-
const datamask = samples[0].dataMask;
8479

85-
// Precompute an array to contain observations
86-
var n_observations = samples.length;
87-
let array = new Array(n_observations).fill(0);
88-
89-
// Fill the array with values
90-
samples.forEach((sample, index) => {
91-
array[index] = samples[index][variable] / scaleFactor;
92-
});
93-
94-
// Get variable and apply scale factor
80+
// use the first sample with a datamask of 1
81+
let datamask = 0;
82+
let val = NaN;
9583
for (var i = 0; i < samples.length; i++) {
96-
indexVal = samples[i][variable] / scaleFactor;
84+
datamask = samples[i].dataMask;
85+
if (datamask == 1) {
86+
val = samples[i].LST / scaleFactor;
87+
break;
88+
}
9789
}
9890

99-
// Display
100-
let imgVals = visualizer.process(indexVal);
10191
return {
102-
default: [...imgVals, datamask],
103-
index: [array],
104-
eobrowserStats: [indexVal, datamask],
92+
default: [...visualizer.process(val), datamask],
93+
index: [val],
94+
eobrowserStats: [val, datamask],
10595
dataMask: [datamask],
10696
};
10797
}

planetary-variables/land-surface-temperature/land-surface-temperature-visualization/index.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ parent: Land Surface Temperature
55
layout: script
66
nav_exclude: false
77
scripts:
8-
- [Visualization, script.js]
9-
- [EO Browser, eob.js]
10-
- [Raw Values, raw.js]
8+
- [Visualization, script.js]
9+
- [EO Browser, eob.js]
10+
- [Raw Values, raw.js]
1111
---
1212

1313
## Evaluate and visualize
@@ -20,6 +20,10 @@ Land Surface Temperature (LST) is the thermodynamic temperature of Earth’s sur
2020

2121
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.
2222

23+
{: .note}
24+
25+
The different times in the day can be selected in the evalscript by changing the variable `sensing_time`. `const sensing_time = "0130";` will return the LST at nighttime and `const sensing_time = "1330";` will return LST at midday.
26+
2327
## Description of representative images
2428

2529
Land Surface Temperature (100 m) on Oct 8, 2023 at 13:30 near Hanover, Germany.
@@ -28,6 +32,6 @@ Land Surface Temperature (100 m) on Oct 8, 2023 at 13:30 near Hanover, Germany.
2832

2933
## References
3034

31-
- [Product specifications](https://planet.widen.net/s/tltwk6hnps)
32-
- [Data sheet](https://planet.widen.net/s/ttvp2rvwzd)
33-
- [Sentinel Hub documentation about Land Surface Temperature](https://docs.sentinel-hub.com/api/latest/data/planet/land-surface-temp/)
35+
- [Product specifications](https://planet.widen.net/s/tltwk6hnps)
36+
- [Data sheet](https://planet.widen.net/s/ttvp2rvwzd)
37+
- [Sentinel Hub documentation about Land Surface Temperature](https://docs.sentinel-hub.com/api/latest/data/planet/land-surface-temp/)

0 commit comments

Comments
 (0)