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.
Arguments
- routes
Routes, the gradients of which are to be calculated. The object must be of class
sf
orsfc
withLINESTRING
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)
class(e)
#> [1] "RasterLayer"
#> attr(,"package")
#> [1] "raster"
crs(e)
#> Coordinate Reference System:
#> Deprecated Proj.4 representation: +proj=longlat +datum=WGS84 +no_defs
#> WKT2 2019 representation:
#> GEOGCRS["unknown",
#> DATUM["World Geodetic System 1984",
#> ELLIPSOID["WGS 84",6378137,298.257223563,
#> LENGTHUNIT["metre",1]],
#> ID["EPSG",6326]],
#> PRIMEM["Greenwich",0,
#> ANGLEUNIT["degree",0.0174532925199433],
#> ID["EPSG",8901]],
#> CS[ellipsoidal,2],
#> AXIS["longitude",east,
#> ORDER[1],
#> ANGLEUNIT["degree",0.0174532925199433,
#> ID["EPSG",9122]]],
#> AXIS["latitude",north,
#> ORDER[2],
#> ANGLEUNIT["degree",0.0174532925199433,
#> ID["EPSG",9122]]]]
e
#> class : RasterLayer
#> dimensions : 345, 585, 201825 (nrow, ncol, ncell)
#> resolution : 6.711421e-05, 6.711421e-05 (x, y)
#> extent : -1.55896, -1.519698, 53.79927, 53.82242 (xmin, xmax, ymin, ymax)
#> crs : +proj=longlat +datum=WGS84 +no_defs
#>
plot(e)
#> Error in .plotraster2(x, col = col, maxpixels = maxpixels, add = add, ext = ext, interpolate = interpolate, colNA = colNA, main = main, addfun = addfun, facvar = facvar, alpha = alpha, npretty = npretty, ...): no values associated with this RasterLayer
plot(st_geometry(routes), add = TRUE)
#> Error in plot.xy(xy.coords(x, y), type = type, ...): plot.new has not been called yet
# }