Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Earth Engine chlorophyll-a demos

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.

Run

# 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-project

If 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-30

Run 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 variables

The 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.

Which "harmonized Sentinel-2"?

"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 conservative Fmask make 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.

What each demo does

s2_ndci_demo.py

  1. Loads the chosen harmonized Sentinel-2 collection, filters by AOI, date and scene-level cloud cover.
  2. Masks clouds/cloud shadow/snow (SCL for s2, Fmask for hls), then masks to water (NDWI > 0 for s2, the Fmask water bit for hls).
  3. Computes NDCI = (B5 - B4) / (B5 + B4) (Mishra & Mishra, 2012), i.e. the red-edge vs. red difference used for chlorophyll in turbid/productive water.
  4. Renders a median true-color composite and median NDCI composite to a folium HTML map.
  5. Reduces NDCI over the AOI for every scene (averaging same-day granules) and plots the time series.

modis_chlor_a_demo.py

  1. Loads daily MODIS-Aqua Level-3 SMI ocean color data and selects the chlor_a band (mg/m³, scale factors already applied).
  2. Masks zero/negative (algorithm failure / fill) pixels.
  3. Renders a median composite and the most recent scene to a folium HTML map.
  4. Reduces chlorophyll-a over the AOI per day and plots the series on a log y-axis.

Caveats

  • 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_a covers 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_a is 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.

Requirements

earthengine-api, folium, pandas, matplotlib (see requirements.txt).

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages