Closed asinghvi17 closed 3 months ago
What is the use case for this? Is it to be able to save the tiles in some local file so that it is possible to plot the basemap without internet connection? I am wondering whether it would make sense to fetch all zoomlevels below a given zoom level and to build a Pyramid out of them.
The idea would be to return a Matrix{RGB}
or even a Raster
, just to make it extremely easy to get a basemap layer to plot. Since Tyler doesn't work without display, this would be a path for people who want to do it manually.
That being said, we should definitely support downloading pyramids for local use. Does PyramidScheme support saving to file?
I am currently working on saving to zarr but that cant be read by Rasters yet. I might look into saving to geotiff.
Pretty easy to add Zarr support to Rasters now with https://github.com/JuliaGeo/ZarrDatasets.jl
@asinghvi17 we could add a RastersMapTilesExt extension for Rasters.jl like for RasterDataSources.jl
Then we can just use the normal constructor syntax but with a provider instead of a file name, and extra keywords:
Raster(provider; extent, [zoomlevel, size, res])
We should also be able to use any Raster/Extexts/GeoInterface object for the extent keyword. Having size
and res
keyword like in Rasters.resample
would help pick the right zoom level rather than using trial and error. You would get the closest possible size/res to the keyword rather than the exact size/res.
That should work nicely! Does Rasters have any image loading dependencies?
No, but probly gdal can do it 😱
The horror :trollface:
I opened a PR for Rasters to add ZarrDatasetsExt.
Should this functionality live her or in TileProviders? I don't understand the boundaries of these packages but saw, that you opened a similar issue on TileProviders.
Huh, I completely forgot about that. I think that implementing it either in an extension on Rasters here or as an extension on MapTiles in Rasters would be the way to go.
The only thing is that we would need some form of image loading library, which might be a pain. ImageIO could probably handle it, and is a Makie dependency so would get automatically pulled in most of the time anyway.
I just wrote a basic script that does this at https://gist.github.com/asinghvi17/cfc8266bc084bc55678c87b5d14dcbc9. It needs HTTP.jl and ImageMagick.jl though, so it may be best to make this a separate package...I'm not sure how we would name it though.
Alternatively, the code could sit in Tyler, since it has all of those dependencies, and then Rasters could implement an extension on Tyler which just dimensionalizes the (x, y, z) output of the function.
Pushed a PR (https://github.com/MakieOrg/Tyler.jl/pull/89) to Tyler along with some conversion methods so you can plot image(provider, extent, size)
- this should substantially improve the situation. Tyler can also now have a RecipesBase extension that adds (a) a recipe for Plots.image
a la what I did in this PR for Makie and potentially something that can query axis size in Plots if that's possible and figure out size and extent automatically.
This would probably be best put in the MapTiles.jl repo, but might also go into Tyler if we need Tyler's dependencies. I envision the method to be something like: