Skip to content

Commit

Permalink
Updated script to be in line with EOB, added note about how to access…
Browse files Browse the repository at this point in the history
… different times in the day
  • Loading branch information
jonasViehweger committed Jan 4, 2024
1 parent d0d7a3e commit 58a27f2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
// LST has two observations per days: 1h30 and 13h30 solar local time

const defaultVis = true; // true or false
const color_min = 290; // default min: 263
const color_max = 330; // default max: 340
const sensing_time = "0130"; // "0130" or "1330" or ""
const variable = "LST"; // LST or LST_MaskedPixels
const color_min = 263; // default min: 263
const color_max = 340; // default max: 340
const sensing_time = "1330"; // "0130" or "1330" or ""

//set the data for map and timeserie
function setup() {
return {
input: [variable, "dataMask"],
input: ["LST", "dataMask"],
output: [
{ id: "default", bands: 4 },
{ id: "index", bands: 1, sampleType: "FLOAT32" },
Expand All @@ -31,13 +30,10 @@ function preProcessScenes(collections) {
collections.scenes.tiles = collections.scenes.tiles.filter(function (tile) {
return tile.dataPath.includes("T" + sensing_time);
});
collections.scenes.tiles.sort(
(a, b) => new Date(b.date) - new Date(a.date)
);
return collections;
}

//Create color ramp 250 - 340 (full range)
//Create color ramp 263 - 340 (full range)
const cmap = [
[263, 0x000004],
[266, 0x06051a],
Expand Down Expand Up @@ -80,28 +76,22 @@ const visualizer = new ColorRampVisualizer(cmap);
function evaluatePixel(samples) {
// LST scale factor
const scaleFactor = 100;
const datamask = samples[0].dataMask;

// Precompute an array to contain observations
var n_observations = samples.length;
let array = new Array(n_observations).fill(0);

// Fill the array with values
samples.forEach((sample, index) => {
array[index] = samples[index][variable] / scaleFactor;
});

// Get variable and apply scale factor
// use the first sample with a datamask of 1
let datamask = 0;
let val = NaN;
for (var i = 0; i < samples.length; i++) {
indexVal = samples[i][variable] / scaleFactor;
datamask = samples[i].dataMask;
if (datamask == 1) {
val = samples[i].LST / scaleFactor;
break;
}
}

// Display
let imgVals = visualizer.process(indexVal);
return {
default: [...imgVals, datamask],
index: [array],
eobrowserStats: [indexVal, datamask],
default: [...visualizer.process(val), datamask],
index: [val],
eobrowserStats: [val, datamask],
dataMask: [datamask],
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ parent: Land Surface Temperature
layout: script
nav_exclude: false
scripts:
- [Visualization, script.js]
- [EO Browser, eob.js]
- [Raw Values, raw.js]
- [Visualization, script.js]
- [EO Browser, eob.js]
- [Raw Values, raw.js]
---

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

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.

{: .note}

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.

## Description of representative images

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

## References

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

0 comments on commit 58a27f2

Please sign in to comment.