HLS: Landsat and Sentinel-2 on one time axis#

Output from the last scheduled build

This example needs earthdata credentials. The figures and printed output below come from the most recent scheduled build, which has them; this build reused that output instead of re-running the example.

HLS v2.0 stacks Landsat 8/9 (L30) and Sentinel-2 (S30) on a common 30 m grid. The loader returns both products in one Dataset with a product coordinate, reading the scene metadata from STAC properties. The default route is NASA’s CMR-STAC (Earthdata Login for the reads); the Planetary Computer mirror needs no account.

import matplotlib.pyplot as plt

import easysnowdata as esd

aoi = (-121.80, 46.82, -121.72, 46.88)

Search first. The frame carries the cloud cover and which satellite flew.

items = esd.optical.hls.search(aoi, "2023-08-01/2023-08-20", cloud_cover=50)
print(items[["datetime", "product", "platform", "eo:cloud_cover"]].to_string())
                                                           datetime product       platform  eo:cloud_cover
HLS.L30.T10TES.2023213T184910.v2.0 2023-08-01 18:49:10.908000+00:00     L30    landsat-8/9               1
HLS.L30.T10TET.2023213T184910.v2.0 2023-08-01 18:49:10.908000+00:00     L30    landsat-8/9               1
HLS.S30.T10TET.2023215T190921.v2.0 2023-08-03 19:21:28.371000+00:00     S30  sentinel-2a/b               2
HLS.S30.T10TES.2023215T190921.v2.0 2023-08-03 19:21:42.558000+00:00     S30  sentinel-2a/b               0
HLS.L30.T10TES.2023220T185525.v2.0 2023-08-08 18:55:25.187000+00:00     L30    landsat-8/9              43
HLS.S30.T10TES.2023220T190919.v2.0 2023-08-08 19:21:42.765000+00:00     S30  sentinel-2a/b              31
HLS.S30.T10TET.2023225T190921.v2.0 2023-08-13 19:21:28.464000+00:00     S30  sentinel-2a/b               1
HLS.S30.T10TES.2023225T190921.v2.0 2023-08-13 19:21:42.650000+00:00     S30  sentinel-2a/b              10
HLS.S30.T10TET.2023227T185919.v2.0 2023-08-15 19:11:24.152000+00:00     S30  sentinel-2a/b               1
HLS.S30.T10TES.2023227T185919.v2.0 2023-08-15 19:11:46.665000+00:00     S30  sentinel-2a/b               0
HLS.L30.T10TES.2023228T185535.v2.0 2023-08-16 18:55:35.330000+00:00     L30    landsat-8/9               0
HLS.L30.T10TET.2023228T185535.v2.0 2023-08-16 18:55:35.330000+00:00     L30    landsat-8/9               0
HLS.S30.T10TET.2023232T185921.v2.0 2023-08-20 19:11:32.843000+00:00     S30  sentinel-2a/b               4
HLS.S30.T10TES.2023232T185921.v2.0 2023-08-20 19:11:40.436000+00:00     S30  sentinel-2a/b               1

Load both products, masked with the default Fmask flags. Fmask is unreliable over snow and ice, which is why masking is opt-in rather than automatic.

hls = esd.optical.hls.load(
    aoi,
    "2023-08-01/2023-08-20",
    bands=["green", "swir16", "Fmask"],
    mask="fmask-default",
    cloud_cover=50,
)
ndsi = esd.processing.ndsi(hls)

fig, axes = plt.subplots(1, min(3, ndsi.sizes["time"]), figsize=(12, 4), sharey=True)
for ax, step in zip(
    [axes] if ndsi.sizes["time"] == 1 else axes, range(ndsi.sizes["time"])
):
    ndsi.isel(time=step).plot.imshow(
        ax=ax, cmap="Blues", vmin=-0.5, vmax=1.0, add_colorbar=False
    )
    when = str(ndsi["time"].values[step])[:10]
    ax.set_title(f"{when} ({str(hls['product'].values[step])})")
    ax.set_aspect("equal")
fig.suptitle("HLS NDSI")
fig.tight_layout()
HLS NDSI, 2023-08-01 (L30), 2023-08-03 (S30), 2023-08-08 (L30)
Ignoring read failure while reading: https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/HLSL30.020/HLS.L30.T10TES.2023213T184910.v2.0/HLS.L30.T10TES.2023213T184910.v2.0.Fmask.tif:1
Ignoring read failure while reading: https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/HLSL30.020/HLS.L30.T10TES.2023213T184910.v2.0/HLS.L30.T10TES.2023213T184910.v2.0.B06.tif:1
Ignoring read failure while reading: https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/HLSL30.020/HLS.L30.T10TES.2023213T184910.v2.0/HLS.L30.T10TES.2023213T184910.v2.0.B03.tif:1
Ignoring read failure while reading: https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/HLSL30.020/HLS.L30.T10TET.2023213T184910.v2.0/HLS.L30.T10TET.2023213T184910.v2.0.Fmask.tif:1
Ignoring read failure while reading: https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/HLSL30.020/HLS.L30.T10TET.2023213T184910.v2.0/HLS.L30.T10TET.2023213T184910.v2.0.B03.tif:1
Ignoring read failure while reading: https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/HLSL30.020/HLS.L30.T10TET.2023213T184910.v2.0/HLS.L30.T10TET.2023213T184910.v2.0.B06.tif:1
Ignoring read failure while reading: https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/HLSS30.020/HLS.S30.T10TET.2023215T190921.v2.0/HLS.S30.T10TET.2023215T190921.v2.0.Fmask.tif:1
Ignoring read failure while reading: https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/HLSS30.020/HLS.S30.T10TET.2023215T190921.v2.0/HLS.S30.T10TET.2023215T190921.v2.0.B03.tif:1
Ignoring read failure while reading: https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/HLSS30.020/HLS.S30.T10TET.2023215T190921.v2.0/HLS.S30.T10TET.2023215T190921.v2.0.B11.tif:1
Ignoring read failure while reading: https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/HLSS30.020/HLS.S30.T10TES.2023215T190921.v2.0/HLS.S30.T10TES.2023215T190921.v2.0.Fmask.tif:1
Ignoring read failure while reading: https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/HLSS30.020/HLS.S30.T10TES.2023215T190921.v2.0/HLS.S30.T10TES.2023215T190921.v2.0.B03.tif:1
Ignoring read failure while reading: https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/HLSS30.020/HLS.S30.T10TES.2023215T190921.v2.0/HLS.S30.T10TES.2023215T190921.v2.0.B11.tif:1
Ignoring read failure while reading: https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/HLSL30.020/HLS.L30.T10TES.2023220T185525.v2.0/HLS.L30.T10TES.2023220T185525.v2.0.B03.tif:1
Ignoring read failure while reading: https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/HLSL30.020/HLS.L30.T10TES.2023220T185525.v2.0/HLS.L30.T10TES.2023220T185525.v2.0.B06.tif:1
Ignoring read failure while reading: https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/HLSL30.020/HLS.L30.T10TES.2023220T185525.v2.0/HLS.L30.T10TES.2023220T185525.v2.0.Fmask.tif:1

The credential-free mirror serves the same scenes for users without an Earthdata account.

mirror = esd.optical.hls.load(
    aoi,
    "2023-08-01/2023-08-06",
    bands=["green"],
    products="S30",
    source="planetary-computer",
    resolution=120,
)
print(mirror.attrs["source"], mirror.attrs["collections"])
planetary-computer hls2-s30

Total running time of the script: (0 minutes 18.651 seconds)