Skip to content

Commit 5d5820b

Browse files
added Penguin Locator script to PlanetScope
1 parent 07ca391 commit 5d5820b

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

planet/planetscope/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,6 @@ The spectral bands of PlanetScope data are the following if you order a 8-band p
5555
- [NDWI]({% link planet/planetscope/ndwi/index.md %})
5656
- [NDCI - Normalized Difference Chlorophyll Index]({% link planet/planetscope/ndci/index.md %})
5757
- [NDRE - Normalized Difference Red Edge Index]({% link planet/planetscope/ndre/index.md %})
58+
- [Penguin Locator - Highlight small differences in snow and ice landscapes]({% link planet/planetscope/penguin_locator/index.md})
5859
- [Green City]({% link planet/planetscope/green_city/index.md %})
5960
- [UDM2 Cloud/Snow Classification]({% link planet/planetscope/cloud_classification/index.md %})
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
title: Penguin Locator
3+
parent: Planet
4+
grand_parent: PlanetScope
5+
layout: script
6+
permalink: /planet/planetscope/penguin_locator/
7+
nav_exclude: true
8+
examples:
9+
- zoom: '10'
10+
lat: '66.4630'
11+
lng: '-38.46067'
12+
datasetId: ccb1f8f0-e5bf-4c31-afe5-d8803bcbde2a
13+
fromTime: '2025-06-04T00:00:00.000Z'
14+
toTime: '2025-06-04T23:59:59.999Z'
15+
platform:
16+
- CDSE
17+
evalscripturl: https://custom-scripts.sentinel-hub.com/custom-scripts/sentinel/sentinel-2/penguin_locator/script.js
18+
---
19+
20+
The layout `script` automatically adds the title defined in the front matter and adds buttons to visualize the script. For the buttons to work the evalscript has to be named `script.js` and must be in the same directory as the `README.md` file.
21+
22+
23+
## General description of the script
24+
25+
This script aims to highlight small patterns in landscapes dominated by ice and snow. It does this by first rescaling to 0-1 to match Sentinel-2 band ranges, then square root transforming all bands, then adding the NIR band to the red channel (more sensitive to ice thickness and wetness than the visible bands), and calculating the differences between the red and green, and green and blue PlanetScope image bands respectively and assigning these to the green and blue channels of the visualized image. The result speaks for itself: subtle patterns in snow and ice cover are revealed, and objects on the surface such as penguin poop stand out, easy to notice.
26+
27+
## References
28+
29+
- See more in this legendary gallery feature: https://dataspace.copernicus.eu/gallery/2024-9-28-monitoring-penguins-space
30+
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//VERSION=3
2+
3+
// Penguin Locator custom script by Rafał Wereszszynski (@kosmi.bluesky.social), adapted to PlanetScope by András Zlinszky and GitHub Copilot.
4+
// This version uses PlanetScope band names and rescales 16-bit integer values (0-10000) to 0-1 for processing.
5+
6+
function setup() {
7+
return {
8+
input: ["blue", "green", "red", "nir"],
9+
output: { bands: 3 }
10+
};
11+
}
12+
13+
function evaluatePixel(sample) {
14+
// Rescale PlanetScope values from 0-10000 to 0-1
15+
var blue = sample.blue / 10000;
16+
var green = sample.green / 10000;
17+
var red = sample.red / 10000;
18+
var nir = sample.nir / 10000;
19+
20+
var r = Math.sqrt(0.6 * nir) - 0.1;
21+
var g = Math.sqrt(0.6 * red) - 0.1;
22+
var b = Math.sqrt(0.6 * green) - 0.1;
23+
24+
var r2 = Math.sqrt(0.6 * nir) - 0.1;
25+
var g2 = Math.sqrt(0.6 * green) - 0.1;
26+
var b2 = Math.sqrt(0.6 * blue) - 0.1;
27+
28+
var dark = 7;
29+
30+
var dif1 = (1 - ((r + r2) / 2)) / dark;
31+
var dif2 = (1 - ((g + g2) / 2)) / dark;
32+
var dif3 = (1 - ((b + b2) / 2)) / dark;
33+
34+
var r3 = ((r + r2) / 2) - dif1;
35+
var g3 = ((g + g2) / 2) - dif2;
36+
var b3 = ((b + b2) / 2) - dif3;
37+
38+
return [r3, g3, b3];
39+
}

0 commit comments

Comments
 (0)