-
Notifications
You must be signed in to change notification settings - Fork 15
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
Fix missing tiles in corners for fast gridding by using off-boundary pixels #255
Merged
joshuacortez
merged 18 commits into
thinkingmachines:master
from
joshuacortez:fix/fast_gridding_corners
Sep 10, 2024
Merged
Fix missing tiles in corners for fast gridding by using off-boundary pixels #255
joshuacortez
merged 18 commits into
thinkingmachines:master
from
joshuacortez:fix/fast_gridding_corners
Sep 10, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…gTileGridGenerator
…in voxel_traversal_scanline_fill
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
tm-jc-nacpil
approved these changes
Sep 10, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! keen to merge it so we can test it out in other repos
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes the missing corner tiles when using FastSquareGridGenerator and FastBingTileGridGenerator
Results
Describing the issue
In the gridding tutorial there is a discrepancy between the regular and the fast version of both square and Bing tile gridding.
The image below shows the mismatch: there is 1 tile available in BingTileGridGenerator but not in FastBingTileGridGenerator (see green tile)
While a 1 tile mismatch might seem innocuous and coincidental, this points to a deeper issue in general. Usage using other AOIs by @tm-jc-nacpil show that FastBingTileGridGenerator can miss even tiles with a large AOI intersection (see bottom left arrow)
Diagnosis
Upon further inspection, I saw this issue is due to 2 things:
The image below is the same AOI and 1 missing tile (shown in green) in terms of pixel coordinates instead of geographic coordinates. Note that the vertical orientation is flipped in pixel coordinates.
Notice how the 1 missing tile in green has a corner that is tangent to the blue line segment. This points to the underlying issue of
off-boundary pixels
. These are pixels whose corners are tangential to an AOI polygon edge. Most importantly, these pixels are candidates for adding back to the main tile set for error correction.You can read more about
off-boundary pixels
in the15_polygon_fill.ipynb
notebook in this PR. Examples ofoff-boundary pixels
in the image below:Resolution
Here are the general steps for the fix:
off-boundary pixels
. Several functions in15_polygon_fill
are updated to return these.off-boundary pixels
that intersect linestring of the AOI boundary. The intersections should be done in terms of geographic coordinates, not pixel coordinates. This is implemented in thegenerate_grid
method in FastSquareGridGenerator and FastBingTileGridGeneratora. Despite this step relying on geometry intersection, the performance hit should be relatively small since we're doing a linestring to polygon intersection (not a polygon to polygon intersection), and the
off-boundary pixels
should be a small fraction of the total tiles.off-boundary pixels
to the main tile setNote that even after this fix, there still isn't a 100% guarantee of a perfect match between the regular and fast versions of gridding, which I suspect can still happen due to floating point precision errors. But the percent match should have nonetheless improved.