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

More convenient methods to get basemaps from MapTiles/Tyler (potentially write to an RGB raster, etc) #37

Closed
asinghvi17 opened this issue Apr 23, 2024 · 13 comments
Assignees

Comments

@asinghvi17
Copy link
Member

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:

basemapraster(provider, extent, zoomlevel)
basemapraster(provider, extent, size::NTuple{2, Int} #=this converts to zoom level internally for convenience=#) 
@felixcremer
Copy link
Member

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.

@asinghvi17
Copy link
Member Author

asinghvi17 commented Apr 23, 2024

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?

@felixcremer
Copy link
Member

I am currently working on saving to zarr but that cant be read by Rasters yet. I might look into saving to geotiff.

@rafaqz
Copy link
Member

rafaqz commented Apr 24, 2024

Pretty easy to add Zarr support to Rasters now with https://github.com/JuliaGeo/ZarrDatasets.jl

@rafaqz
Copy link
Member

rafaqz commented Apr 24, 2024

@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.

@asinghvi17
Copy link
Member Author

That should work nicely! Does Rasters have any image loading dependencies?

@rafaqz
Copy link
Member

rafaqz commented Apr 24, 2024

No, but probly gdal can do it 😱

@asinghvi17
Copy link
Member Author

The horror :trollface:

@felixcremer
Copy link
Member

I opened a PR for Rasters to add ZarrDatasetsExt.

@felixcremer
Copy link
Member

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.

@asinghvi17
Copy link
Member Author

asinghvi17 commented Apr 28, 2024

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.

@asinghvi17 asinghvi17 self-assigned this Jul 6, 2024
@asinghvi17
Copy link
Member Author

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.

@asinghvi17
Copy link
Member Author

asinghvi17 commented Jul 6, 2024

Pushed a PR (MakieOrg/Tyler.jl#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.

@asinghvi17 asinghvi17 closed this as completed by moving to Done in JuliaCon 2024 Hackathon Jul 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

3 participants