
Download or read elevation (SRTM-style DEM)
geo_elevation.RdFetches a digital elevation model for a bounding box or set of sites,
with an on-disk cache and an offline path for local GeoTIFFs. Prefers
geodata (SRTM via elevation_*) when installed, then elevatr,
then a user-supplied file. Cite Jarvis et al. (2008) / NASA SRTM when
publishing maps that use these surfaces.
Usage
geo_elevation(
data = NULL,
lon = lon,
lat = lat,
bbox = NULL,
path = NULL,
cache_dir = NULL,
download = TRUE,
z = 5,
buffer = 0.1
)Arguments
- data
Optional data frame of sites with
lon/latused to build the bounding box whenbboxisNULL.- lon, lat
Coordinate columns of
data.- bbox
Numeric vector
c(xmin, ymin, xmax, ymax)in WGS84, or ansf/SpatExtentobject.- path
Local GeoTIFF (or directory of GeoTIFFs) for offline use.
- cache_dir
Cache directory. Defaults to
tools::R_user_dir("tidymapr", "cache")/elevation.- download
Download when the cache is empty? Set
FALSEon CRAN or offline runners.- z
Zoom / resolution hint for elevatr (1-14). Ignored by geodata.
- buffer
Extra degrees added around the site bbox (default 0.1).
Value
A terra::SpatRaster elevation surface (metres).
References
Jarvis, A., Reuter, H. I., Nelson, A. and Guevara, E. (2008). Hole-filled SRTM for the globe Version 4. CGIAR-CSI. https://srtm.csi.cgiar.org/
Examples
dem <- geo_example_dem()
terra::nlyr(dem)
#> [1] 1