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

Inconsistent handling of extents #1766

Closed
AdeelH opened this issue Apr 5, 2023 · 2 comments · Fixed by #1774
Closed

Inconsistent handling of extents #1766

AdeelH opened this issue Apr 5, 2023 · 2 comments · Fixed by #1774
Labels

Comments

@AdeelH
Copy link
Collaborator

AdeelH commented Apr 5, 2023

Raster/vector/label sources have an extent property that can either refer to the full extent of the data in the source file or a user-specified subset of it. Currently, the latter case is not being handled correctly everywhere.

@AdeelH AdeelH added the bug label Apr 5, 2023
@AdeelH
Copy link
Collaborator Author

AdeelH commented Apr 6, 2023

@lewfish, which of the following do you think looks more intuitive? Currently, RV is doing a mix of both which is buggy.

Option 1

Pixel indices correspond to the pixel indices in the source file. So, e.g., the first chip_sz=5 window will have a different address depending on the crop. This is simpler and closer to how RV used to handle this in earlier versions.

rs = RasterioSource(..., extent=Box(10, 10, 20, 20))
rs.extent # Box(10, 10, 20, 20)

rs.get_chip(Box(0, 0, 5, 5)) # outside the extent so blank chip
rs.get_chip(Box(10, 10, 15, 15)) # correct window to get the first chip (chip_sz=5)

rs[:5, :5] # equivalent to rs.get_chip(Box(0, 0, 5, 5)), blank chip
rs[10:15, 10:15] # equivalent to rs.get_chip(Box(10, 10, 15, 15)), first legit chip

Option 2

Here, pixel indices are relative to the crop. So the first chip_sz=5 window will always be Box(0, 0, 5, 5) regardless of the crop, which is arguably more user-friendly.

rs = RasterioSource(..., bbox=Box(10, 10, 20, 20))
rs.extent # Box(0, 0, 10, 10), always == (0, 0, H, W)
rs.bbox # Box(10, 10, 20, 20)

rs.get_chip(Box(0, 0, 5, 5)) # correct window to get the first chip (chip_sz=5)
rs.get_chip(Box(10, 10, 15, 15)) # outside the extent so blank chip

rs[:5, :5] # equivalent to rs.get_chip(Box(0, 0, 5, 5)), first legit chip
rs[10:15, 10:15] # equivalent to rs.get_chip(Box(10, 10, 15, 15)), blank chip

@lewfish
Copy link
Contributor

lewfish commented Apr 6, 2023

@AdeelH The second option seems more intuitive to me, and I would prefer that.

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

Successfully merging a pull request may close this issue.

2 participants