q37·intermediate

Are the mangroves and coastal wetlands that protect my shore shrinking?

biospherecoastalhydrologyclimate Datasets: 3 30–60 min
Find the data for your area

Draw a rectangle to pick your area of interest, then see what NASA data covers it (live, here in your browser) or download a ready-to-run notebook with your AOI pre-filled. The notebook runs in any Python environment — it needs a free Earthdata Login to fetch the data.

Current AOI: 88.8, 21.6 → 89.3, 22 (Sundarbans mangroves, Bangladesh/India)

Mangroves are the quiet seawall in front of millions of people — they break waves, trap sediment, and hold the shoreline together. When they thin out or get cleared, the coast behind them gets more exposed. NASA's **HLSL30** (Harmonized Landsat) gives a 30 m, cloud-screened look at the land surface every few days, so you can turn the red and near-infrared bands into a greenness index ([NDVI](/glossary/ndvi/)) and watch a mangrove belt fill in or fade over time. **Verified locally.** For the Sundarbans (21.6–22.0 °N, 88.8–89.3 °E) on 4 Jan 2024, an HLSL30 scene gave a **median NDVI of 0.64** across the AOI, with **57% of pixels above 0.6** — the signature of a dense, healthy mangrove canopy threaded by tidal channels (the open-water channels pull the lower quartile negative, exactly as you'd expect in a delta). NDVI tells you how green and leafy the canopy is; to say a mangrove has actually been *lost* (not just browned for a season), you compare the same patch across years and cross-check against a mangrove-extent baseline.

Are the mangroves and coastal wetlands that protect my shore shrinking?

Mangroves are the quiet seawall in front of millions of people — they break waves, trap sediment, and hold the shoreline together. When they thin out or get cleared, the coast behind them gets more exposed. NASA’s HLSL30 (Harmonized Landsat) gives a 30 m, cloud-screened look at the land surface every few days, so you can turn the red and near-infrared bands into a greenness index (NDVI) and watch a mangrove belt fill in or fade over time.

Verified locally. For the Sundarbans (21.6–22.0 °N, 88.8–89.3 °E) on 4 Jan 2024, an HLSL30 scene gave a median NDVI of 0.64 across the AOI, with 57% of pixels above 0.6 — the signature of a dense, healthy mangrove canopy threaded by tidal channels (the open-water channels pull the lower quartile negative, exactly as you’d expect in a delta). NDVI tells you how green and leafy the canopy is; to say a mangrove has actually been lost (not just browned for a season), you compare the same patch across years and cross-check against a mangrove-extent baseline.

What you can answer

  • How dense and green the mangrove canopy is right now — NDVI = (B05 − B04) / (B05 + B04) from HLSL30, at 30 m, anywhere on the coast
  • Whether the canopy is thinning or filling in over years — compute NDVI for the same dry-season window each year and difference them to see gains and losses
  • Where along the shore the change is concentrated — map the NDVI difference to find specific eroding fronts, cleared patches, or recovering replanting zones
  • Roughly how wide the protective green belt is — threshold NDVI (e.g. > 0.5) to outline the vegetated buffer between open water and inhabited land
  • Open-water vs. land context — overlay JRC Global Surface Water to separate permanent channels and ponds from the wetland canopy, and Global Mangrove Watch for a known mangrove footprint

What you can NOT answer with these datasets alone

  • Whether a green pixel is truly mangrove — NDVI cannot tell mangrove from rice, palm, or other coastal vegetation; you need Global Mangrove Watch or field knowledge to confirm species
  • Seasonal browning vs. real loss — a single low-NDVI scene can be a dry spell, a cloud artifact, or tidal flooding; only multi-year, same-season comparison separates loss from cycles
  • Why it changed — satellite greenness shows the what, not the cause (cyclone, clearing, salinity, subsidence, sea-level rise)
  • Below-ground carbon or root health — HLS sees the canopy top, not the soil carbon or root mass that make mangroves valuable for storage and stability
  • Sub-30 m detail — thin fringe mangroves a few metres wide can hide inside a 30 m pixel; pair with higher-resolution imagery for narrow belts
  • Marsh or seagrass below the waterline — submerged or intertidal wetlands are poorly seen by an optical land index; treat water-edge pixels with caution

Code template (Python, cloud-direct)

Verified locally. HLSL30 ships as Cloud-Optimized GeoTIFFs (one file per band). Open the red (B04) and near-infrared (B05) bands with rioxarray, clip to your bounding box before computing, and take the median NDVI. Dense mangrove reads ~0.6–0.9; open water reads negative.

import os, re, warnings, earthaccess, rioxarray, numpy as np
warnings.filterwarnings("ignore")

# load Earthdata creds from .env without `source` (passwords can break the shell)
for line in open(".env"):
    m = re.match(r'\s*(?:export\s+)?([A-Z0-9_]+)\s*=\s*(.*)\s*$', line)
    if m: os.environ.setdefault(m.group(1), m.group(2).strip().strip('"').strip("'"))
earthaccess.login(strategy="environment")   # free Earthdata Login

W, S, E, N = 88.8, 21.6, 89.3, 22.0          # your coast (Sundarbans)
results = earthaccess.search_data(short_name="HLSL30",
                                  temporal=("2024-01-01", "2024-03-31"),
                                  bounding_box=(W, S, E, N), count=60)

# HLS is COGs: grab the B04 (red) and B05 (NIR) .tif links from a low-cloud scene
urls = results[0].data_links()
b04 = next(u for u in urls if "B04" in u and u.endswith(".tif"))
b05 = next(u for u in urls if "B05" in u and u.endswith(".tif"))
files = earthaccess.open([b04, b05])         # authenticated file handles

red = rioxarray.open_rasterio(files[0], masked=True).rio.clip_box(W, S, E, N, crs="EPSG:4326")
nir = rioxarray.open_rasterio(files[1], masked=True).rio.clip_box(W, S, E, N, crs="EPSG:4326")

ndvi = (nir.values - red.values) / (nir.values + red.values)
ndvi = ndvi[np.isfinite(ndvi)]
print("median NDVI:", round(float(np.median(ndvi)), 3))   # ~0.64 dense mangrove
print("fraction > 0.6:", round(float((ndvi > 0.6).mean()), 3))

# to detect loss: rerun for the same dry-season window in an earlier year and
# difference the two NDVI maps — persistent drops are candidate mangrove loss
How a scientist answers this
Parameters
Canopy greenness NDVI = (B05 − B04)/(B05 + B04) from HLSL30 30 m surface reflectance, summarized as median and the fraction of pixels above ~0.6 inside a mangrove mask, with Global Mangrove Watch extent defining where mangroves are and JRC Global Surface Water masking permanent open water/tidal channels.
Method
Composite cloud-screened HLSL30 scenes within the same dry-season window each year (median NDVI to suppress residual cloud/tide effects), apply the GMW mangrove mask and JRC water mask, then difference matched annual composites to map per-pixel NDVI gain/loss; require multi-year persistence to call a real loss rather than a seasonal browning.
Validation
Use a fixed dry-season window and the same mask across years, cross-check declines against GMW extent change and visually against HLSL imagery, and note tidal stage, mixed pixels at channel edges, and cloud-gap effects as biases.
In plain EnglishMeasure how green the mangrove canopy is from satellite each dry season, compare the same patches across years, and flag where greenness drops in step with a known mangrove map.

Make it yours → Set the coastline AOI, the dry-season months, the years to difference, and the NDVI-loss threshold in the notebook.

Run the core method · no login

The robust trend (Theil–Sen + Mann–Kendall) at the heart of this question — runnable on synthetic data, right here. The full earthaccess code template further down does it on real NASA data (needs an Earthdata login).

editable · runs in your browser

Datasets used