Skip to contents

elevation_get() uses the cc_elevation() function from the ceramic package to get DEM data in raster format anywhere worldwide. It requires an API that can be added by following guidance in the package's README and in the slopes vignette.

Usage

elevation_get(routes, ..., output_format = "raster")

Arguments

routes

Routes, the gradients of which are to be calculated. The object must be of class sf or sfc with LINESTRING geometries.

...

Options passed to cc_elevation()

output_format

What format to return the data in? Accepts "raster" (the default) and "terra".

Value

A raster object with cell values representing elevations in the bounding box of the input routes object.

Details

Note: if you use the cc_elevation() function directly to get DEM data, you can cache the data, as described in the package's README.

Examples

# Time-consuming examples that require an internet connection and API key:
# \donttest{
library(sf)
library(raster)
routes = cyclestreets_route
e = elevation_get(routes)
#> Error: data source could not be processed with GDALWarp api
class(e)
#> Error: object 'e' not found
crs(e)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'crs': object 'e' not found
e
#> Error: object 'e' not found
plot(e)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'plot': object 'e' not found
plot(st_geometry(routes), add = TRUE)
#> Error in plot.xy(xy.coords(x, y), type = type, ...): plot.new has not been called yet
# }