Learn R Programming

movecost (version 3.0.0)

mc_dtm: Download elevation data for a study area

Description

Acquires a Digital Terrain Model from online sources (via the elevatr package) for the area enclosed by the supplied polygon, and crops it to the polygon's extent. This replaces the implicit download mechanism of movecost <= 2.x's studyplot parameter (which remains available in mc_surface and simply calls this function).

Usage

mc_dtm(studyplot, z = 9)

Value

A SpatRaster.

Arguments

studyplot

polygon (sf, SpatVector, or legacy sp class) representing the study area for which elevation data are acquired.

z

zoom level of the downloaded elevation data (0 to 15; 9 by default).

Details

The zoom level z controls the resolution of the downloaded data (default 9, a trade-off between resolution and download time). For details on the data sources and the ground resolution per zoom level, see the elevatr documentation: https://cran.r-project.org/package=elevatr.

Note: the downloaded raster is returned in the CRS provided by the source. Before using it with mc_surface, make sure it is in a projected CRS (reproject with terra::project() if needed); a geographic (lon/lat) raster is rejected by mc_surface() with an informative error.

See Also

mc_surface

Examples

Run this code
if (FALSE) {
# elevation data for the area around Mt Etna (sample polygon in the package)
boundary <- mc_etna_boundary()
dtm <- mc_dtm(boundary, z = 9)
}

Run the code above in your browser using DataLab