Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"errors_as_nodata" not working correctly #243

Open
fkroeber opened this issue Mar 6, 2024 · 1 comment
Open

"errors_as_nodata" not working correctly #243

fkroeber opened this issue Mar 6, 2024 · 1 comment

Comments

@fkroeber
Copy link

fkroeber commented Mar 6, 2024

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()
fkroeber referenced this issue Apr 24, 2024
Mute potential errors due to unexpected shapes
@PGuti
Copy link

PGuti commented May 7, 2024

I'm experiencing the exact same error using:

  • rasterio=='1.3.9'
  • xarray=='2023.12.0'
  • planetary_computer=='1.0.0'
  • stackstac=='0.5.0'
  • dask =='2024.2.0'

EDIT: So we made our code work by downgrading to stackstac 0.4.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants