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

Allow float tile_buffer #405

Merged

Conversation

bstadlbauer
Copy link
Contributor

Some tile data such a certain digital elevation models (DEMs) default to an uneven tile size (e.g. 257x257). They have an overlap of one pixel on each side, and assume that each pixel is not an "area" but a point measurement. It would be nice, if COGReader.tile() would support this use case.

I found the tile_buffer parameter, which would do this exact thing. However, as it only supports integers, only overlaps of two pixel are possible. This PR changes the signature of tile_buffer to be Optional[Union[int, float]] where the float case is restricted to halves of integers, to ensure an integer tilesize

@vincentsarago
Copy link
Member

Thanks @bstadlbauer 🙏

I wonder if we could just allow integer and explicitly tell that the value will be divided by 2 🤷‍♂️

Adding a test to check if the tile_buffer is a multiple of 0.5 seems a bit weird TBH.

I'll wait for @kylebarron and @geospatial-jeff input

@bstadlbauer
Copy link
Contributor Author

That's also something that I thought about. For me, both versions don't seem quite right so I went with the one not breaking the existing API.

I am flexible here, just let me know and I adjust the code as required.

@vincentsarago vincentsarago requested review from kylebarron and removed request for kylebarron July 27, 2021 21:53
@vincentsarago vincentsarago changed the base branch from master to rio-tiler-v3 October 18, 2021 11:51
@vincentsarago
Copy link
Member

@bstadlbauer I've rebased this PR to the new rio-tiler-branch and updated the if test and docstring.

I'll wait for 👍 / 👎 from @geospatial-jeff before merging

Copy link
Member

@geospatial-jeff geospatial-jeff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks great! I wonder if it is more intuitive to change the tile_buffer argument to instead be an absolute buffer. Currently the tile buffer argument is really a padding that is added to all sides of the tile. Instead we could update the argument such that a tile buffer of 1 would result in 257x257 and a tile buffer of 2 would result in 258x258 (assuming your tile size is 256). Obviously this would be a breaking change but maybe that's fine since this will be released with v3.

FWIW I think the current implementation is fine, so please disregard this comment if you don't agree.

@vincentsarago
Copy link
Member

thanks @geospatial-jeff. We all agree current implementation is fine. I'll add a note in the documentation to make sure users understand what the value of tile_buffer is.

@vincentsarago vincentsarago merged commit fe3fd98 into cogeotiff:rio-tiler-v3 Oct 19, 2021
vincentsarago added a commit that referenced this pull request Oct 19, 2021
* switch to morecantile3 (#418)

* switch to morecantile3

* remove python 3.6

* make sure to use rio-cogeo2.3.1 in tests

* 🤦

* use rio-cogeo from github

* update fixtures and tests

* update changelog

* deprecate metadata methods (#425)

* zxy -> xyz in SpatialMixin.tile_exits method (#419)

* No max size (#422)

* remove default max_size for part and feature

* ignore type, failing in python 3.9

* use rio-cogeo alpha

* Use RIO_TILER_MAX_THREADS instead of MAX_THREADS (#432)

* MAX_THREADS to RIO_TILER_MAX_THREADS

* Update env variable in docs

* Add to changelog

* Update CHANGES.md

Co-authored-by: Vincent Sarago <vincent.sarago@gmail.com>

* allow non-earth dataset (#429)

* allow non-earth dataset

* fix stac

* metadata/info returns `geographic_bounds`

* add test for non earth object tile reading

* add notebook

* update changelog

* update docs

* update

* revert and remove min/max zoom in __init__

* edit changes

* Use httpx (#431)

* Replace requests with httpx

* Use httpx instead of requests

* Use httpx in notebooks

* Add tox to dev requirements

* Revert change and remove unused import

* update changelog

Co-authored-by: Vincent Sarago <vincent.sarago@gmail.com>

* add new statistics methods and band names in ImageData object (#427)

* add new statistics methods and band names in ImageData object

* update base classes and tests

* MultiBandReader.statistics should use self.preview as COGReader

* update tests

* start migration docs

* update docs

* remove `band_expression` option in MultiBandReader (#437)

* Asset expression indexes (#438)

* change asset_expression type and add asset_indexes

* update changelog

* moar docs

* Allow float tile_buffer (#405)

* Add tests of the expected behaviour

* Add `tile_buffer` `float` support in `COGReader.tile()`

* :facepalm

Co-authored-by: Bernhard Stadlbauer <bstadlbauer@blackshark.ai>
Co-authored-by: vincentsarago <vincent.sarago@gmail.com>

* update docs and allow backward compat for indexes in MultiBaseReader

* Range colormap (#439)

* add range colormap support

* update docs

* update types

* s/range/intervals/g

* remove deprecated code and update docs (#440)

* remove deprecated code and update docs

* update changelog

Co-authored-by: Rodrigo Almeida <rodrigo@developmentseed.org>
Co-authored-by: bstadlbauer <11799671+bstadlbauer@users.noreply.github.com>
Co-authored-by: Bernhard Stadlbauer <bstadlbauer@blackshark.ai>
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

Successfully merging this pull request may close these issues.

4 participants