Penguin Locator

//VERSION=3

// Penguin Locator custom script by Rafał Wereszszynski (@kosmi.bluesky.social), adapted to PlanetScope by András Zlinszky and GitHub Copilot.
// This version uses PlanetScope band names and rescales 16-bit integer values (0-10000) to 0-1 for processing.

function setup() {
  return {
    input: ["blue", "green", "red", "nir"],
    output: { bands: 3 }
  };
}

function evaluatePixel(sample) {
  // Rescale PlanetScope values from 0-10000 to 0-1
  var blue = sample.blue / 10000;
  var green = sample.green / 10000;
  var red = sample.red / 10000;
  var nir = sample.nir / 10000;

  var r = Math.sqrt(0.6 * nir) - 0.1;
  var g = Math.sqrt(0.6 * red) - 0.1;
  var b = Math.sqrt(0.6 * green) - 0.1;

  var r2 = Math.sqrt(0.6 * nir) - 0.1;
  var g2 = Math.sqrt(0.6 * green) - 0.1;
  var b2 = Math.sqrt(0.6 * blue) - 0.1;

  var dark = 7;

  var dif1 = (1 - ((r + r2) / 2)) / dark;
  var dif2 = (1 - ((g + g2) / 2)) / dark;
  var dif3 = (1 - ((b + b2) / 2)) / dark;

  var r3 = ((r + r2) / 2) - dif1;
  var g3 = ((g + g2) / 2) - dif2;
  var b3 = ((b + b2) / 2) - dif3;

  return [r3, g3, b3];
}

Evaluate and Visualize

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.

General description of the script

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.

References

  • See more in this legendary gallery feature: https://dataspace.copernicus.eu/gallery/2024-9-28-monitoring-penguins-space