Skip to content

"errors_as_nodata" not working correctly #243

@fkroeber

Description

@fkroeber

In the following example, the errors_as_nodata parameter of stackstac.stack() causes a shape-related error down the way. The NodataReader returns an object with 2 dimensions missing the band dimension ("Unexpected shape (485, 1024), expected exactly 1 band.").

import planetary_computer as pc
import stackstac 
from pystac_client import Client
from rasterio.errors import RasterioIOError
from shapely.geometry import box

# load some data with broken links
t_start = "2022-05-15"
t_end = "2022-06-01"
xmin, ymin, xmax, ymax = 142.13,-34.2,142.18,-34.15

catalog = Client.open(
    "https://planetarycomputer.microsoft.com/api/stac/v1", 
    modifier=pc.sign_inplace
    )
query = catalog.search(
    collections="landsat-c2-l2",
    datetime=[t_start, t_end],
    limit=100,
    intersects=box(xmin, ymin, xmax, ymax)
)
item_coll = query.item_collection()
item_coll

# try to stack them 
cube = stackstac.stack(
    item_coll,
    assets=["red"],
    epsg=3857,
    resolution=(30,30),
    errors_as_nodata=(RasterioIOError(".*"),),
    xy_coords="center",
    snap_bounds=False,
)
data = cube.compute()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions