Two standalone Python demos that plot chlorophyll-a / chlorophyll-a proxies in Google Earth Engine:
| Script | Dataset | Chlorophyll signal | Resolution |
|---|---|---|---|
scripts/s2_ndci_demo.py |
COPERNICUS/S2_SR_HARMONIZED (default) or NASA/HLS/HLSS30/v002 (--product hls) |
NDCI (B5, B4) | 20 m / 30 m |
scripts/modis_chlor_a_demo.py |
NASA/OCEANDATA/MODIS-Aqua/L3SMI (NASA MODIS-Aqua) |
chlor_a band (mg/m³) |
~4.6 km |
Both scripts use the same AOI/date options, build an interactive map of a seasonal composite, and write a time series plot plus CSV:
outputs/s2_ndci_map.html outputs/modis_chlor_a_map.html
outputs/s2_ndci_timeseries.png outputs/modis_chlor_a_timeseries.png
outputs/s2_ndci_timeseries.csv outputs/modis_chlor_a_timeseries.csv
With --product hls the Sentinel-2 demo writes hls_ndci_* files instead.
# 1. Harmonized Sentinel-2, NDCI chlorophyll proxy (Tampa Bay, summer 2023)
python scripts/s2_ndci_demo.py --project my-gee-project
# 2. NASA MODIS-Aqua chlorophyll-a (same AOI, full year 2023)
python scripts/modis_chlor_a_demo.py --project my-gee-projectIf Earth Engine asks for a Cloud project, pass it with --project (a project
registered for Earth Engine) or set EE_PROJECT.
The defaults point at Tampa Bay, Florida (-82.55, 27.72, 30–50 km radius).
Point them anywhere with water:
# Lake Taihu, China
python scripts/s2_ndci_demo.py --lon 120.20 --lat 31.20 --buffer-km 20 \
--start 2023-06-01 --end 2023-09-30
python scripts/modis_chlor_a_demo.py --lon 120.20 --lat 31.20 --buffer-km 20 \
--start 2023-06-01 --end 2023-09-30Run either script with -h for all options (--product, --cloud-filter,
--scale, --outdir, ...), or use the Makefile:
make s2 PROJECT=my-gee-project # Sentinel-2 NDCI
make hls PROJECT=my-gee-project # HLS S30 variant
make modis PROJECT=my-gee-project # MODIS chlorophyll-a
make all PROJECT=my-gee-project # both
make help # targets and variablesThe Makefile takes the same settings as variables (LON, LAT,
S2_START, S2_END, MODIS_START, MODIS_END, OUTDIR, ...), plus
ARGS for anything else.
Maps are plain Leaflet pages (via folium) using Esri World Imagery tiles, so they open directly from disk with no API key or notebook widgets.
"Landsat-harmonized Sentinel-2" can mean two different GEE collections, so the script supports both:
--product s2(default): ESA's Harmonized Sentinel-2 Level-2A (COPERNICUS/S2_SR_HARMONIZED). Processing baselines are harmonized across the archive. This is the standard product for water/chlorophyll work.--product hls: NASA HLS S30 (NASA/HLS/HLSS30/v002), where Sentinel-2 is reprocessed and bandpass-adjusted to match Landsat on a 30 m grid. HLS is built for land; its BRDF-normalized reflectance and conservativeFmaskmake it a weaker choice over turbid coastal water (NDCI often comes out negative).
For chlorophyll-a, keep the default s2 unless you specifically need HLS
consistency with Landsat.
- Loads the chosen harmonized Sentinel-2 collection, filters by AOI, date and scene-level cloud cover.
- Masks clouds/cloud shadow/snow (
SCLfors2,Fmaskforhls), then masks to water (NDWI > 0fors2, theFmaskwater bit forhls). - Computes NDCI =
(B5 - B4) / (B5 + B4)(Mishra & Mishra, 2012), i.e. the red-edge vs. red difference used for chlorophyll in turbid/productive water. - Renders a median true-color composite and median NDCI composite to a folium HTML map.
- Reduces NDCI over the AOI for every scene (averaging same-day granules) and plots the time series.
- Loads daily MODIS-Aqua Level-3 SMI ocean color data and selects the
chlor_aband (mg/m³, scale factors already applied). - Masks zero/negative (algorithm failure / fill) pixels.
- Renders a median composite and the most recent scene to a folium HTML map.
- Reduces chlorophyll-a over the AOI per day and plots the series on a log y-axis.
- NDCI is not chlorophyll-a concentration. It is a relative index. Convert to mg/m³ only with a calibration fitted to in-situ data for the same water body and season.
- NDCI assumes turbid, productive water. In clear open ocean, blue/green
ratio algorithms are more appropriate; MODIS
chlor_acovers that case. - MODIS is 4.6 km. Small lakes and narrow estuaries will be mixed with land or missed entirely; use Sentinel-2 there.
- MODIS
chlor_ais tuned for case-1 water and can be biased in turbid coastal or inland water. - HLS is BRDF-normalized (NBAR) and built for land; water pixels are valid but the corrections are not designed for water color.
- Cloud gaps are normal. The time series only includes scenes that pass the cloud filter and have unmasked water pixels in the AOI.
earthengine-api, folium, pandas, matplotlib (see
requirements.txt).