-
-
Notifications
You must be signed in to change notification settings - Fork 86
Re-implementation of tile merging based on mercantile #50
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
Conversation
Excellent! I think this will make |
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.
Tests should be passing now.
Added some comments to explain the changes in the tests.
assert_array_almost_equal(ext, (0.0, 939258.2035682457, | ||
6261721.35712164, 6887893.492833804)) | ||
assert_array_almost_equal(ext, (0.0, 939258.2035682457, | ||
6261721.35712164, 6887893.492833804)) |
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.
this was duplicated with the line above
assert_array_almost_equal(ext, (0.0, 939258.2035682457, | ||
6261721.35712164, 6887893.492833804)) | ||
rtr_bounds = [-613.0928221724841, 6262334.050013727, | ||
938645.1107460733, 6888506.185725891] |
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.
This needed to be updated, because the shape of the img
array changed (and therefore also the transform calculation when writing the merged tiles with rasterio)
assert_array_almost_equal(ax_extent, ax.images[0].get_extent()) | ||
assert ax.images[0].get_array().sum() == 75687792 | ||
assert ax.images[0].get_array().shape == (256, 511, 3) | ||
assert ax.images[0].get_array().sum() == 75853866 |
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.
all those small number changes are due to the fact that the 1 row/column on 256 is no longer incorrectly dropped when merging the tiles -> see also the shape changes; they are now multiples of 256)
Nice!!! I'd say, add documentation for |
This PR removed the use of cartopy's
merge_tiles
with a custom implementation(related to https://github.com/darribas/contextily/issues/4 and SciTools/cartopy#792).
It seemed this tile merging can actually rather easily be done, using some of the features of
mercantile
(which is already used to calculate the web tile x and y numbers given the zoom and bounds), and using some assumptions about the fact that we only deal with web map tiles (all rectangular equal sized images for a given extent).Just pushing this now to show the implementation. I didn't yet look at or update the tests.
I actually expect the tests to be failing, as while doing this, I discovered that there is a bug in the current implementation (we are overlaying the tiles with one pixel overlap, so losing one pixel row, which gave a subtle hardly noticeable difference (only noted it by comparing the final array of both methods, you need to zoom in a lot to actually see it in the image).