-
Notifications
You must be signed in to change notification settings - Fork 29
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
/statistics errors due to different dimensions of mosaic mask and cropped array #122
Comments
I have one more clue. The incongruent shapes ( from rio_tiler.io.stac import STACReader
item_ids = ["1459200_2304000", "1536000_2304000"]
for item_id in item_ids:
with STACReader(f"{stac_endpoint}/collections/{collection}/items/{item_id}") as stac:
img = stac.feature(
shape=geojson["features"][0],
assets=["public"],
)
print(f"item {item_id}: {img.mask.shape}") item 1459200_2304000: (30, 27)
item 1536000_2304000: (31, 28) When I dial for item_id in item_ids:
with STACReader(f"{stac_endpoint}/collections/{collection}/items/{item_id}") as stac:
img = stac.feature(
shape=geojson["features"][0],
assets=["public"],
max_size=29,
)
print(f"item {item_id}: {img.mask.shape}") item 1459200_2304000: (29, 27)
item 1536000_2304000: (29, 27) Shouldn't the |
Hi @hrodmn, This should be handled in https://github.com/cogeotiff/rio-tiler/blob/main/rio_tiler/models.py#L442-L454 or maybe there is a bug! The issue when using 🤦 oh but for Mosaic we don't check this 🤦 (this is why part/feature shouldn't be used in production 😓) We should patch rio-tiler https://github.com/cogeotiff/rio-tiler/blob/main/rio_tiler/mosaic/methods/defaults.py#L22 to first check if we can merge the data all together. The best would be to use |
Thanks for the info, @vincentsarago! I think I have found a workaround for this issue: if I project the coordinates to the same CRS as the items in the STAC collection (which is always epsg:5070 in my case) then set
Yeah, I see the resolutions are different in the Affine transforms for the two
Are there any other reasons why I shouldn't use
To do that we would need to add |
The issues are:
Yeah that's could be a solution, but I don't think you'll get the resolution of each assets before really opening them (except if they all have the proj extension)
oh yeah that's a good idea we should replace the max_size dependency with https://github.com/developmentseed/titiler/blob/main/src/titiler/core/titiler/core/dependencies.py#L309-L320 |
This is now fixed in latest rio-tiler version https://github.com/cogeotiff/rio-tiler/blob/main/CHANGES.md#610-2023-09-15 But we are still blocked by stac-utils/pgstac#201 before we can update titiler / titiler-pgstac |
I am running titiler-pgstac in an eoAPI deployment and have been working on an application that uses the /statistics endpoint to handle some zonal statistics. It is working really well 90% of the time, but I am hitting errors on polygons that cross STAC item boundaries (polygons that do not cross STAC item boundaries seem to be working fine).
Here is an example traceback for one of the errors:
This happens when I use the default value for the
maxsize
parameter, but if I dialmaxsize
down to a smaller number (e.g. 29 in this case), the request succeeds.The ultimate error is occurring here:
https://github.com/cogeotiff/rio-tiler/blob/main/rio_tiler/mosaic/methods/defaults.py#L23
I haven't been able to reproduce the runtime environment yet, but it seems as if the dimensions of
img
andFirstMethod.mosaic.mask
are not the expected size.Possibly this is not a bug in
titiler-pgstac
and is related to STAC item metadata instead?Any advice on how to debug would be greatly appreciated!
The text was updated successfully, but these errors were encountered: