Skip to content

Commit b4c674f

Browse files
added simple panchromatic script
1 parent 248e913 commit b4c674f

File tree

5 files changed

+73
-0
lines changed

5 files changed

+73
-0
lines changed

sentinel-2/sentinel-2.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ Dedicated to supplying data for [Copernicus services](https://www.esa.int/Our_Ac
156156
- [Aesthetic Neon](/sentinel-2/aesthetic-neon) - Aesthetic visualization for urban and dry (desert) areas
157157
- [Total Ozone Column over Antarctica snow](/sentinel-2/ozone_column_over_snow)
158158
- [BRDF normalisation](/sentinel-2/brdf)
159+
- [Simple Panchromatic](/sentinel-2/simple_panchromatic) - Create a simple greyscale visualization by averaging the 10m true color and NIR bands
159160

160161
#### Scripts including machine learning techniques (eo-learn)
161162

426 KB
Loading
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: Sentinel-2 Simple Panchromatic
3+
parent: sentinel-2
4+
layout: script
5+
nav_exclude: true
6+
scripts:
7+
- - Sentinel-2
8+
- script.js
9+
- - Sentinel-2 Quarterly Cloudless Mosaics
10+
- script_mosaics.js
11+
examples:
12+
- zoom: '14'
13+
lat: '42.76703'
14+
lng: '36.823'
15+
datasetId: S2L2A
16+
fromTime: '2025-03-03T00:00:00.000Z'
17+
toTime: '2025-03-03T23:59:59.999Z'
18+
platform:
19+
- CDSE
20+
- EOB
21+
evalscripturl: https://custom-scripts.sentinel-hub.com/custom-scripts/sentinel-2\simple_panchromatic\script.js
22+
---
23+
24+
## General description of the script
25+
26+
This script is for creating a simple panchromatic greyscale visualization from Sentinel-2. It simulates the way a panchromatic band works by taking the average of bands 2 (Red), 3 (Green), 4 (Blue), and 8 (wide-band near infrared). The suggested use is for backgrounds in a scene compare, or as an input for pansharpening of lower resolution bands. The script also works for quarterly cloudless mosaics.
27+
28+
## Description of representative images
29+
30+
This scene is a Sentinel-2 image of Nairobi, Kenya
31+
32+
!['Sentinel-2 simple panchromatic image of Nairobi, Kenya on 3 March 2025'](.\img\nairobi.jpg)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//VERSION=3
2+
//Simple Panchromatic visualization of Sentinel-2 data, using the mean of the band intensities for Red, Green, Blue and Near Infrared
3+
//By András Zlinszky, Sinergise - with help from GitHub Copilot
4+
//https://bsky.app/profile/azlinszky.bsky.social
5+
6+
function setup() {
7+
return {
8+
input: ["B01", "B02", "B03", "B08", "dataMask"],
9+
output: { bands: 4 }
10+
};
11+
}
12+
13+
const gain = 2.5;
14+
15+
function evaluatePixel(sample) {
16+
// Calculate the mean of the bands
17+
let pan = (sample.B01 + sample.B02 + sample.B03 + sample.B08) / 4;
18+
19+
return [gain * pan, gain * pan, gain * pan, sample.dataMask];
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//VERSION=3
2+
//Simple Panchromatic visualization of Sentinel-2 data, using the mean of the band intensities for Red, Green, Blue and Near Infrared
3+
//By András Zlinszky, Sinergise - with help from GitHub Copilot
4+
//https://bsky.app/profile/azlinszky.bsky.social
5+
6+
function setup() {
7+
return {
8+
input: ["B01", "B02", "B03", "B08", "dataMask"],
9+
output: { bands: 4 }
10+
};
11+
}
12+
13+
const gain = 0.00025;
14+
15+
function evaluatePixel(sample) {
16+
// Calculate the mean of the bands
17+
let pan = (sample.B01 + sample.B02 + sample.B03 + sample.B08) / 4;
18+
19+
return [gain * pan, gain * pan, gain * pan, sample.dataMask];
20+
}

0 commit comments

Comments
 (0)