Landsat 8 (Microsoft Planetary Computer)
Overview
landsat8_mpc streams Landsat 8 Collection 2 Level-2 surface reflectance directly from the Microsoft Planetary Computer (MPC) STAC API. The verb signs COG URLs using the planetary_computer SDK and stacks the requested bands into a lazy, dask-backed DataArray with dimensions (time, band, y, x).
Quickstart
Get the stream (CubeDynamics grammar)
import cubedynamics as cd
from cubedynamics import pipe, verbs as v
bbox = [-105.35, 39.9, -105.15, 40.1]
cube = (
pipe(None)
| v.landsat8_mpc(bbox=bbox, start="2019-07-01", end="2019-07-10")
).unwrap()
ndvi = (cube.sel(band="nir") - cube.sel(band="red")) / (cube.sel(band="nir") + cube.sel(band="red"))
pipe(ndvi) | v.plot(time_dim="time")
Preview plot

!!! note
Image placeholder — after running the code below locally, save a screenshot to docs/assets/datasets/landsat8_mpc-preview.png.
Regenerate this plot
- Run the Quickstart snippet to stream a small Landsat 8 stack and compute NDVI.
-
Capture the viewer returned by the plotting verb:
python viewer = (pipe(ndvi) | v.plot(time_dim="time")).unwrap() viewer.save("docs/assets/datasets/landsat8_mpc-preview.html") -
Open
docs/assets/datasets/landsat8_mpc-preview.htmlin a browser and save a 1200×700 px PNG screenshot todocs/assets/datasets/landsat8_mpc-preview.png.
Required arguments
bbox–[min_lon, min_lat, max_lon, max_lat]geographic bounding box.start– ISO start date string (e.g., `"2019-07-01").end– ISO end date string (e.g., `"2019-08-01").
Optional arguments
band_aliases– tuple of band aliases to pull (default("red", "nir")).max_cloud_cover– maximum allowedeo:cloud_coverpercentage (default50).chunks_xy– optional dask chunk sizes forxandy(e.g.,{ "x": 1024, "y": 1024 }).stac_url– STAC API endpoint, defaults to the MPC service.
Return structure
A lazy :class:xarray.DataArray backed by dask with dimensions (time, band, y, x). Data are not loaded until you compute or plot.
Basic usage
from cubedynamics import pipe, verbs as v
bbox = [-105.35, 39.9, -105.15, 40.1]
cube = (
pipe(None)
| v.landsat8_mpc(
bbox=bbox,
start="2019-07-01",
end="2019-08-01",
)
).unwrap()
NDVI example
After streaming, compute NDVI from the red and near-infrared bands:
red = cube.sel(band="red")
nir = cube.sel(band="nir")
ndvi = (nir - red) / (nir + red)
# Visualize the time series interactively
pipe(ndvi) | v.plot(time_dim="time")
For visualization, you can avoid loading huge rotated footprints by using the downsampling helper:
from cubedynamics.verbs import landsat_ndvi_plot
landsat_ndvi_plot(
bbox=bbox,
start="2019-07-01",
end="2019-08-01",
)
The landsat_vis_ndvi/landsat_ndvi_plot helpers crop all-NaN borders and coarsen the cube so v.plot remains responsive, while the raw v.landsat8_mpc output stays available for analysis at full resolution.
Notes
- This verb uses MPC-signed STAC assets; no additional credentials are required.
- Because the DataArray is dask-backed, subsequent analysis and visualization remain lazy until execution.
Back to Datasets Overview
Next recommended page: Which dataset should I use?