NO2 Monthly mean
//VERSION=3
// By Jonas Viehweger, Sinergise
var minVal = 0.0;
var maxVal = 0.0001;
const map = [
[0, 0x00007f],
[1, 0x0000ff],
[2, 0x00ffff],
[3, 0xffff00],
[4, 0xff0000],
[5, 0x7f0000]
];
const visualizer = new ColorRampVisualizer(map, minVal, maxVal)
function setup() {
return {
input: ["NO2","dataMask"],
output: [
{ id: "default", bands: 4 },
{ id: "index", bands: 1, sampleType: "FLOAT32" },
{ id: "eobrowserStats", bands: 1, sampleType: "FLOAT32"},
{ id: "dataMask", bands: 1 },
],
mosaicking: "ORBIT"
};
}
function isClear(sample) {
return sample.dataMask == 1;
}
function sum(array) {
let sum = 0;
for (let i = 0; i < array.length; i++) {
sum += array[i].NO2;
}
return sum;
}
function evaluatePixel(samples) {
const clearTs = samples.filter(isClear)
const mean = sum(clearTs) / clearTs.length
const [r, g, b] = visualizer.process(mean);
const dataMask = clearTs.length > 0;
return {
default: [r, g, b, dataMask],
index: [mean],
eobrowserStats: [mean],
dataMask: [dataMask],
};
}
Evaluate and Visualize
General description of the script
This script calculates the mean values of NO2 over the time period you select. It is useful for visualizing large-scale patterns of air pollution. In order to comply with the SI unit definitions, the TROPOMI NO2 data product gives trace gas concentrations in mol/m2.
Cloud-affected pixels are masked from Sentinel-5P air pollution imagery, you will see them as empty pixels on the map. Due to the relatively low resolution of Sentinel-5P TROPOMI, these datasets work best at regional to continental scale, however, at such scales it is extremely rare to encounter an image that is not influenced by clouds. Therefore, similar to Sentinel-2 quarterly mosaics, creating longer-term mean mosaics of Sentinel-5P data enables exploring pollution patterns across regions.
The script is written to work for NO2, but can be used for other Sentinel-5P data layers as well by manually changing the variable “NO2” in the setup function and in the sum(array) function.
Representative image
This image shows the monthly mean NO2 concentration for January 2024 over Central Europe. You can see the major urban centers of Northern Germany, Belgieum and the Netherlands, the Rhine valley, the Czech basin, and the high pollutant concentration in the Po valley.
View in Copernicus Browser here