Open
Description
Default stackstac.stack parameters are (in my experience) for all stac catalogs I tried providing incorrect pixel coordinates.
First here is an example showing up the shift created by stackstac.stack default parameters, should we default 'snap_bounds' to False & 'xy_coords' to "center" instead?
Let's gather some data
import stackstac
import pystac_client
import rasterio
import rioxarray as rxr
utm = 32615
bbox = [-90.47116362, 33.50472389, -90.37408012, 33.54915847] # wgs84
buffer = 10
smaller_bbox = [729975-buffer, 3770025-buffer, 729975+buffer, 3770025+buffer] # local utm
params = dict(
collections=["sentinel-2-l2a"],
bbox=bbox,
datetime='2023-06-01/2023-06-15',
query={
# "eo:cloud_cover": {"lt": 20},
# "landsat:collection_category": {"eq": "T1"},
# "landsat:collection_number": {"eq": "02"},
# "platform": {"in": ["LANDSAT_8", "LANDSAT_9"]},
# "landsat:correction": {"eq": "L2SP"},
},
)
href = "https://earth-search.aws.element84.com/v1"
c = pystac_client.Client.open(href)
s = c.search(**params)
_ = s.matched()
xs = s.item_collection()
Then do some plots
img_rxr = rxr.open_rasterio(xs[0].assets["red"].href).squeeze()
img_rxr.rio.clip_box(*smaller_bbox).plot()
stac_img = stackstac.stack(xs, assets=["red"])\
.sel(time = str(xs[0].properties["datetime"])[:-2])\
.squeeze()
stac_img.rio.clip_box(*smaller_bbox).plot.imshow()
stac_img = stackstac.stack(xs, assets=["red"], snap_bounds=False, xy_coords="center", )\
.sel(time = str(xs[0].properties["datetime"])[:-2])\
.squeeze()
stac_img.rio.clip_box(*smaller_bbox).plot.imshow()
Please confirm it's not only me. It seems like the convention default is confusing right?
Metadata
Metadata
Assignees
Labels
No labels