Skip to content

"errors_as_nodata" not working correctly #243

New issue

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

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

Already on GitHub? # to your account

Closed
fkroeber opened this issue Mar 6, 2024 · 2 comments · Fixed by #256
Closed

"errors_as_nodata" not working correctly #243

fkroeber opened this issue Mar 6, 2024 · 2 comments · Fixed by #256

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.

gjoseph92 added a commit that referenced this issue Aug 10, 2024
Opted not to refactor `NodataReader` as described in comments because #232 removes it all together, and I don't need even more merge conflicts someday.

Fixes #243
@gjoseph92
Copy link
Owner

Thanks for reporting @fkroeber. I believe this should be fixed in #256.

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

Successfully merging a pull request may close this issue.

3 participants