USEPA / elevatr

An R package for accessing elevation data
Other
202 stars 25 forks source link

Feature request: support a wider range of zoom scales in get_elev_raster #54

Closed karldw closed 3 years ago

karldw commented 3 years ago

Hello,

Thanks for the useful package! I'm looking for fairly high resolution elevations, and was encouraged that the Joerd data sources document mentions zoom levels up to 15. https://github.com/tilezen/joerd/blob/master/docs/data-sources.md#what-is-sourced-at-what-zooms

Would it be possible for elevatr to support higher zoom levels? Currently the max is 14. The data sources page mentions levels 15 and 16. (It's possible you'd want to support even higher zooms if you add support for the USGS 1-meter data, e.g. https://github.com/jhollist/elevatr/issues/44).

I'm not positive what internal changes would be involved. The first issue I ran into was with estimate_raster_size, which assumes a maximum of 14.

https://github.com/jhollist/elevatr/blob/4f03fb26745ec1aced774dde8d04f5f5458acbea/R/internal.R#L214-L220

Reprex:

library(elevatr)

x <- get_elev_raster(lake, z = 15)
#> Error in if (dl_size > 100 & dl_size < 500) {: argument is of length zero
jhollist commented 3 years ago

Thanks for this. I will take a look, although not sure when I'll get the time to do it. But it will be on my list next time I get back to elevatr. Sorry I can't get to it right now!

karldw commented 3 years ago

Thanks!

jhollist commented 3 years ago

Took a quick look at this and I am not sure zoom levels beyond 14 are actually supported by the API. As you point, they are listed in the documentation, but when I amend my code to create the URLs they fail. Would need to look in closer just to make sure my code that grabs the tile x and y isn't doing something wrong, but at this point I think elevatr might be limited by the AWS Terrain Tiles API.

karldw commented 3 years ago

Ah, thank you! I think you're right about the AWS terrain tiles. I just tried out ceramic::cc_elevation, which (I think) pulls the same AWS tiles, and it also doesn't work past zoom 14. (The CRAN version of that package, 0.6.0, has a bug in cc_elevation that generates an error requesting the AWS tiles, but it's fixed in the github version.)