Skip to content

enable algorithm chaining #1139

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

Open
vincentsarago opened this issue Apr 24, 2025 · 6 comments
Open

enable algorithm chaining #1139

vincentsarago opened this issue Apr 24, 2025 · 6 comments
Labels
enhancement New feature or request help wanted Extra attention is needed question Further information is requested

Comments

@vincentsarago
Copy link
Member

It would be nice if we could chain Algorithm.

Question: Some algorithms need options, how would a user pass options for specific algo?
Possible answer: In STAC we have a custom format "{asset}|{indexes}" (red|1,2,3) to enable indexes selection per assets

@vincentsarago vincentsarago added enhancement New feature or request help wanted Extra attention is needed question Further information is requested labels Apr 24, 2025
@vincentsarago
Copy link
Member Author

ref #1116 (comment)

cc @jo-chemla

@davidbrochart
Copy link

Sorry in advance if this is out of the scope of this issue, but I was wondering if one could also specify where in the data pipeline an algorithm should be applied. Correct me if I'm wrong, but it seems that currently it is only possible to apply an algorithm after the data has been reprojected. But what if one wants to apply an algorithm on each tile before reprojection?
My use-case is visualizing flow accumulation, which is a good proxy for potential river flow. This kind of dataset is special in that the value of interest is encoded in a point, meaning that a big river will have a big flow accumulation in a point, with neighbors having a much smaller flow accumulation. It is therefore very important to carefully down-sample the data (in each tile), and in particular not choose to aggregate points using a "mean" function, but using a "max" function. Otherwise there will be discontinuities in rivers, as seen here:

Screencast.from.2025-05-08.15-26-12.webm

@vincentsarago
Copy link
Member Author

Correct me if I'm wrong, but it seems that currently it is only possible to apply an algorithm after the data has been reprojected

Yes

But what if one wants to apply an algorithm on each tile before reprojection?

Sadly this won't be possible without heavy transformation off how titiler work. The xarray is pretty different from the other regular reader because we do read the data before doing reprojection, but for rasterio based reader we do everything in one call (so we don't have access to the non-reprojected data.

While I love that titiler can do a lot of things, sadly it won't fit 100% user needs sometimes :-(

It is therefore very important to carefully down-sample the data (in each tile), and in particular not choose to aggregate points using a "mean" function, but using a "max" function. Otherwise there will be discontinuities in rivers, as seen here:

Well right now I have no control about how the downsampling/oversampling is done in the XarrayReader feel free to have a look at https://github.com/cogeotiff/rio-tiler/blob/c93e772949e1734415b78faadae4a99fbd18820a/rio_tiler/io/xarray.py#L346-L366 🙏

@davidbrochart
Copy link

Well right now I have no control about how the downsampling/oversampling is done in the XarrayReader feel free to have a look at https://github.com/cogeotiff/rio-tiler/blob/c93e772949e1734415b78faadae4a99fbd18820a/rio_tiler/io/xarray.py#L346-L366 🙏

For my particular use-case, it seems that I'd need GDAL's GRA_Max warp resampling algorithm, but I have no idea how I could then pass it to the reproject_method argument.

@vincentsarago
Copy link
Member Author

you should be able to pass reproject=max once cogeotiff/rio-tiler#800 is published 😅

@davidbrochart
Copy link

Great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants