Learn R Programming

ElevDistr (version 1.0.9)

calculate_distance: Sample and calculate the distance to the local treeline

Description

Points are uniformly drawn along polygons that specify the treeline. The elevation of each point is then extracted and the median elevation of all points is calculated. Finally the median treeline elevation is subtracted from the pointElevation to get its distance to the local treeline.

Usage

calculate_distance(treeline, elevationRaster, pointElevation, treelineSampling = 10,
                         plot = FALSE)

Value

Returns a numeric representing the vertical distance to the local treeline in meters.

Arguments

treeline

A data frame containing line-shaped polygons. Each row containing: a identifier, a start latitude and longitude, an end latitude and longitude. All longitude and latitude (WGS 84) parameters must be of the data type "numeric" and finite.

elevationRaster

Raster that contains a digital elevation model. Data type "SpatRaster".

pointElevation

Elevation of the point of interest (in meters above the sea level). One value, data type "numeric" and finite.

treelineSampling

A constant number of samples taken from one "treeline piece". One value, data type "integer", finite and not zero.

plot

Boolean that defines if a histogram of the sampled elevation is plotted. The plot will only be shown if the value is TRUE.

Author

Livio Bätscher, Jurriaan M. de Vos

Examples

Run this code
if (FALSE) {
calculate_distance(treeline = dfTreeline, elevationRaster = GTOPO30, pointElevation = 512,
                   treelineSampling = 10, plot = FALSE)
}

Run the code above in your browser using DataLab