Registry / analytics / stackstac

stackstac

JSON →
library0.5.1pypypi✓ verified 83d ago

Load SpatioTemporal Asset Catalog (STAC) items into xarray DataArrays with Dask support. Version 0.5.1. Active development; release cadence irregular.

pip install stackstac
INSTALL
IMPORT
SIG · STACKSTAC
S
stackstac
analyticspythonv0.5.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

stackstac
import stackstac
from stackstac import stackstac
The main module is the package itself; no submodule named stackstac.

Stack Landsat items from Planetary Computer into an xarray DataArray with 30m resolution in Web Mercator.

import stackstac import pystac_client import planetary_computer as pc catalog = pystac_client.Client.open( "https://planetarycomputer.microsoft.com/api/stac/v1", modifier=pc.sign_inplace ) search = catalog.search(collections=["landsat-c2-l2"], bbox=[-72, 42, -70, 44]) items = [item for item in search.items()] ds = stackstac.stack(items, resolution=30, epsg=3857) da = ds["red"] print(da)
Debug
Known issues
breakingIn version 0.5.0, the default for `gdal_env` changed from False to True. This may break workflows relying on no GDAL environment configuration.
fix
Explicitly set gdal_env=False in stackstac.stack() to restore old behavior.
affects: >=0.5.0
gotchaStacked DataArrays have dimensions (time, y, x). If items have different resolutions, the coarsest resolution is used unless `resolution` is explicitly set.
fix
Always specify the target resolution with the `resolution` parameter to avoid surprises.
affects: all
gotchaBy default, `stackstac.stack()` references the raster asset's full-resolution image without downsampling; if you need lower spatial resolution set the `resolution` parameter explicitly.
fix
Use `resolution=<desired_meters>` to control output pixel size.
affects: all
deprecatedThe `epsg` parameter was deprecated in 0.5.0 in favor of `crs`. Provide `crs` as an EPSG code or CRS object.
fix
Replace `epsg=4326` with `crs=4326`.
affects: >=0.5.0
Errors
Common errors & fixes
KeyError: 'proj:epsg'
One or more items are missing the `proj:epsg` property in their STAC metadata.
fix
Manually provide an EPSG code using the `crs` parameter: `ds = stackstac.stack(items, crs=4326)`
UnboundLocalError: local variable 'cog' referenced before assignment
The asset's href is not a Cloud Optimized GeoTIFF (COG) and the `assets` parameter is misconfigured.
fix
Ensure specified assets are COGs; use `assets=['B04', 'B03', 'B02']` correctly spelled and available in the item.
ValueError: No valid items found.
The STAC search returned no items or none of the items have the required asset bands.
fix
Check the search query; verify the collection has the assets (e.g., 'red' not 'B04').
Upgrade
Version history
0.5.1latest on PyPI · released Aug 10, 2024
Audit
Dependencies
rasteriorequiredGDAL-backed raster I/O
xarrayrequiredArray data structures
daskoptionalParallel computing
pystac-clientoptionalSTAC API client
Agent activity
40 hits · last 30 days
node
36
Resources

No resource links recorded.

stackstac — pip install stackstac · libregistry