-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #290 from ajgeers/planet/soil-water-content
Add Soil Water Content and Land Surface Temperature scripts
- Loading branch information
Showing
6 changed files
with
217 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
title: Land Surface Temperature | ||
parent: Planetary Variables | ||
layout: script | ||
permalink: /planetary-variables/land-surface-temperature/ | ||
nav_exclude: false | ||
--- | ||
|
||
## Evaluate and visualize | ||
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. | ||
|
||
## General description | ||
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. | ||
|
||
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. | ||
|
||
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. | ||
|
||
## Description of representative images | ||
Land Surface Temperature (100 m) on Oct 8, 2023 at 13:30 near Hanover, Germany. | ||
|
||
![Land Surface Temperature example](fig/lst.jpg) | ||
|
||
## 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/) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
//VERSION=3 | ||
|
||
// Set defaultVis to false to scaled and choose color_min and color_max values. | ||
// 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 | ||
|
||
//set the data for map and timeserie | ||
function setup() { | ||
return { | ||
input: [variable, "dataMask"], | ||
output: [{ id: "default", bands: 4 }, | ||
{ id: "index", bands: 1, sampleType: 'FLOAT32' }, | ||
{ id: "eobrowserStats", bands: 1, sampleType: 'FLOAT32' }, | ||
{ id: "dataMask", bands: 1 }], | ||
mosaicking: "TILE" | ||
}; | ||
} | ||
|
||
//Select files based on sensing time (0130 or 1330) | ||
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) | ||
const cmap = [ | ||
[263, 0x000004], | ||
[266, 0x06051a], | ||
[270, 0x140e36], | ||
[274, 0x251255], | ||
[278, 0x3b0f70], | ||
[282, 0x51127c], | ||
[286, 0x641a80], | ||
[289, 0x782281], | ||
[293, 0x8c2981], | ||
[297, 0xa1307e], | ||
[301, 0xb73779], | ||
[305, 0xca3e72], | ||
[309, 0xde4968], | ||
[313, 0xed5a5f], | ||
[316, 0xf7705c], | ||
[320, 0xfc8961], | ||
[324, 0xfe9f6d], | ||
[328, 0xfeb77e], | ||
[332, 0xfecf92], | ||
[336, 0xfde7a9], | ||
[340, 0xfcfdbf], | ||
]; | ||
|
||
//updated color ramp based on color_min and color_max | ||
function updateCMap(min, max) { | ||
const numIntervals = cmap.length | ||
const intervalLength = (max - min) / (numIntervals - 1); | ||
for (let i = 0; i < numIntervals; i++) { | ||
cmap[i][0] = min + intervalLength * i | ||
} | ||
} | ||
|
||
// update the min max of color bar if defaultVis set to false | ||
if (!defaultVis) updateCMap(color_min, color_max); | ||
|
||
//initialize the ColorRamp | ||
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 | ||
for (var i = 0; i < samples.length; i++) { | ||
indexVal = samples[i][variable] / scaleFactor; | ||
} | ||
|
||
// Display | ||
let imgVals = visualizer.process(indexVal); | ||
return { | ||
default: [...imgVals, datamask], | ||
index: [array], | ||
eobrowserStats: [indexVal, datamask], | ||
dataMask: [datamask] | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
title: Soil Water Content | ||
parent: Planetary Variables | ||
layout: script | ||
permalink: /planetary-variables/soil-water-content/ | ||
nav_exclude: false | ||
--- | ||
|
||
## Evaluate and visualize | ||
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. | ||
|
||
## General description | ||
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. | ||
|
||
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. | ||
|
||
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. | ||
|
||
## Description of representative images | ||
Soil Water Content (L band 100 m) on Sep 30th, 2023 near Hanover, Germany. | ||
|
||
![Soil Water Content example](fig/swc.jpg) | ||
|
||
## References | ||
- [Product specifications](https://planet.widen.net/s/5xtzljjwgg) | ||
- [Data sheet](https://planet.widen.net/s/cv7bfjhhd5) | ||
- [Sentinel Hub documentation about Soil Water Content](https://docs.sentinel-hub.com/api/latest/data/planet/soil-water-content/) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
//VERSION=3 | ||
const vmin = 0 | ||
const vmax = 0.4 | ||
|
||
function setup() { | ||
return { | ||
input: ["SWC", "dataMask"], | ||
output: [ | ||
{ id: "default", bands: 4 }, | ||
{ id: "index", bands: 1, sampleType: 'FLOAT32' }, | ||
{ id: "eobrowserStats", bands: 1, sampleType: 'FLOAT32' }, | ||
{ id: "dataMask", bands: 1 } | ||
] | ||
}; | ||
} | ||
|
||
function updateColormap(vmin, vmax) { | ||
const numIntervals = cmap.length | ||
const intervalLength = (vmax - vmin) / (numIntervals - 1); | ||
for (let i = 0; i < numIntervals; i++) { | ||
cmap[i][0] = vmin + intervalLength * i | ||
} | ||
} | ||
|
||
const cmap = [ | ||
[0.00, 0xfff7ea], | ||
[0.05, 0xfaedda], | ||
[0.10, 0xede4cb], | ||
[0.15, 0xdedcbd], | ||
[0.20, 0xced3af], | ||
[0.25, 0xbdcba3], | ||
[0.30, 0xaac398], | ||
[0.35, 0x96bc90], | ||
[0.40, 0x80b48a], | ||
[0.45, 0x68ac86], | ||
[0.50, 0x4da484], | ||
[0.55, 0x269c83], | ||
[0.60, 0x009383], | ||
[0.65, 0x008a85], | ||
[0.70, 0x008186], | ||
[0.75, 0x007788], | ||
[0.80, 0x006d8a], | ||
[0.85, 0x00618c], | ||
[0.90, 0x00558d], | ||
[0.95, 0x00478f], | ||
[1.00, 0x003492], | ||
]; | ||
|
||
updateColormap(vmin, vmax); | ||
const visualizer = new ColorRampVisualizer(cmap); | ||
|
||
function evaluatePixel(sample) { | ||
let scaleFactor = 1000 | ||
let val = sample.SWC / scaleFactor; | ||
|
||
let imgVals = visualizer.process(val); | ||
return { | ||
default: [...imgVals, sample.dataMask], | ||
index: [val], | ||
eobrowserStats: [val], | ||
dataMask: [sample.dataMask] | ||
}; | ||
} |