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

Script to generate GeoTIFF from ZXY tile server #811

Merged
merged 3 commits into from Aug 15, 2019
Merged

Script to generate GeoTIFF from ZXY tile server #811

merged 3 commits into from Aug 15, 2019

Conversation

@lewfish
Copy link
Contributor

@lewfish lewfish commented Aug 6, 2019

This PR adds a script to generate a GeoTIFF from a ZXY tile server URI schema, bounds in lng/lat format, and a zoom level. It correctly crops the image based on the bounds, and also works on TMS format tile servers. This lays the groundwork for a ZXYRasterSource and may be independently useful.

It is tested with unit tests, and I also ran it on an example. I created a tile set from a GeoTIFF using gdal2tiles, got some bounds in QGIS, ran the script, and checked that the output was correct.

root@70d4aadebe15:/opt/src# python -m rastervision.data.raster_source.zxy2geotiff "/opt/data/hippo-tiles/{z}/{x}/{-y}.png" 17 \
>     "39.950380846608667 -75.163183288636375 39.951604868181825 -75.158675638636367" \
>     /opt/data/hippo-tiles/out.tif

in

out

@lewfish
Copy link
Contributor Author

@lewfish lewfish commented Aug 6, 2019

Note: tiles in example were created using

conda install gdal
pip install gdal2tiles
gdal2tiles.py /opt/data/hippos.tif -z 17 /opt/data/hippo-tiles

in the fastai Docker image. (there was trouble installing it in the main RV image)

@@ -0,0 +1,182 @@
import tempfile
Copy link
Contributor

@lossyrob lossyrob Aug 6, 2019

Choose a reason for hiding this comment

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

I understand why this is here (it'll be used by a raster source), but I think this would be more discoverable if it was moved to the rastervision.utils package. I can see these methods being imported as a utility by other code that just wants to grab geotiffs from zxy endpoints.

@lewfish
Copy link
Contributor Author

@lewfish lewfish commented Aug 7, 2019

I updated according to your suggestion and added a --make-cog option using your code.

@lewfish lewfish merged commit ab4f016 into master Aug 15, 2019
1 check passed
@lewfish lewfish deleted the lf/zxy branch Aug 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants