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

[READY] Web optimized #40

Closed
wants to merge 11 commits into from
Closed

[READY] Web optimized #40

wants to merge 11 commits into from

Conversation

vincentsarago
Copy link
Member

@vincentsarago vincentsarago commented Nov 14, 2018

replaces #22
resolves #10

@perrygeo @sgillies this is almost the same code as in #22 but I've cut the commits in part to make it clearer. I've added comment in the PR to help.

Basically this PR introduce a --web option to create a COG aligned with the web mercator grid. To do so we need to use WarpedVRT which change the structure of the code (see: 5da9cdf)

capture d ecran le 2018-11-14 a 12 10 19

vrt_transform = Affine(vrt_res, 0, w, 0, -vrt_res, n)

vrt_width = (extrema["x"]["max"] - extrema["x"]["min"]) * 256
vrt_height = (extrema["y"]["max"] - extrema["y"]["min"]) * 256
Copy link
Member Author

Choose a reason for hiding this comment

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

👆 this need to be validated (@dnomadb 😄 ?)


# TODO: What does this means when alpha is passed ?
if utils.has_alpha_band(src):
vrt_params.update(dict(add_alpha=False))
Copy link
Member Author

Choose a reason for hiding this comment

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

#38 this is going to change a lot of the logic, I'll open another ticket to speak about mask/alpha/nodata IN/OUT options



def get_max_zoom(src, snap=0.5, max_z=23):
"""Calculate raster max zoom level."""
Copy link
Member Author

@vincentsarago vincentsarago Nov 14, 2018

Choose a reason for hiding this comment

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

Need docs and tests

def test_cogeo_valid_external_mask(monkeypatch):
"""Should work as expected."""
monkeypatch.setenv("GDAL_TIFF_INTERNAL_MASK", "FALSE")
monkeypatch.setenv("GDAL_DISABLE_READDIR_ON_OPEN", "FALSE")
Copy link
Member Author

@vincentsarago vincentsarago Nov 14, 2018

Choose a reason for hiding this comment

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

I had GDAL_DISABLE_READDIR_ON_OPEN=EMPTY_DIR set in my end, so gdal/rasterio wasn't able to find the .msk file. This change is unrelated to the PR but make sure it will work on any system. I could remove it if needed.


# loop through the pyramid to file the closest z level
for z in range(1, max_z):
mpp = _meters_per_pixel(z, 0)
Copy link
Member Author

Choose a reason for hiding this comment

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

We should maybe take latitude into account here

@vincentsarago
Copy link
Member Author

@sgillies @perrygeo this is ready to review.

That's said there is still some open question we need to answer:

@vincentsarago vincentsarago changed the title [WIP] Web optimized [READY] Web optimized Nov 22, 2018
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.

Add --web option to create ZXY tiles friendly file
1 participant