Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Green City Script

/*
Author of the script: Carlos Bentes
*/

// Normalized Difference Vegetation Index
var ndvi = (B08-B04)/(B08+B04);

// Threshold for vegetation
var veg_th = 0.4;

// Simple RGB
var R = 2.5*B04;
var G = 2.5*B03;
var B = 2.5*B02;

// Transform to Black and White
var Y = 0.2*R + 0.7*G + 0.1*B;
var pixel = [Y, Y, Y];

// Change vegetation color
if(ndvi >= veg_th)
  pixel = [0.1*Y, 1.8*Y, 0.1*Y];

return pixel;

Evaluate and Visualize

General description of the script

Uses NDVI [1] to color Sentinel-2 images and create awareness of green areas in cities around the World.

Author of the script

Carlos Bentes

Description of representative images

Visualization of Tallinn with the Green City script. Green City script over Tallinn

Visualization of Paris with the Green City script. Green City script over Paris

Visualization of Beijing with the Green City script. Green City script over Beijing

References

[1] Normalized difference vegetation index: https://en.wikipedia.org/wiki/Normalized_difference_vegetation_index

Credits

Y. Zha, J. Gao & S. Ni (2003) Use of normalized difference built-up index in automatically mapping urban areas from TM imagery, International Journal of Remote Sensing, 24:3, 583-594, DOI: 10.1080/01431160304987