elevation_extract | R Documentation |
This function takes a series of points located in geographical space
and a digital elevation model as inputs and returns a vector of
elevation estimates associated with each point.
The function takes locations
represented as a matrix of XY (or longitude latitude) coordinates
and a digital elevation model (DEM) with class raster
or terra
.
It returns a vector of values representing estimates of elevation
associated with each of the points.
elevation_extract(
m,
dem,
method = "bilinear",
terra = has_terra() && methods::is(dem, "SpatRaster")
)
m |
Matrix containing coordinates and elevations or an sf object representing a linear feature. |
dem |
Raster overlapping with |
method |
The method of estimating elevation at points,
passed to the |
terra |
Should the |
By default, the elevations are estimated using
bilinear interpolation
(method = "bilinear"
)
which calculates point height based on proximity to the centroids of
surrounding cells.
The value of the method
argument is passed to the method
argument in
raster::extract()
or
terra::extract()
depending on the class of the input raster dataset.
See Kidner et al. (1999) for descriptions of alternative elevation interpolation and extrapolation algorithms.
A vector of elevation values.
Kidner, David, Mark Dorey, and Derek Smith. "What’s the point? Interpolation and extrapolation with a regular grid DEM." Fourth International Conference on GeoComputation, Fredericksburg, VA, USA. 1999.
dem = dem_lisbon_raster
elevation_extract(lisbon_road_network[1, ], dem)
m = sf::st_coordinates(lisbon_road_network[1, ])
elevation_extract(m, dem)
elevation_extract(m, dem, method = "simple")
# Test with terra (requires internet connection):
if(slopes:::has_terra()) {
et = terra::rast(dem_lisbon_raster)
elevation_extract(m, et)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.