Learn R Programming

elpatron (version 0.0.4)

elevation_correct: Elevation correction

Description

Extracts (reliable) elevation data from raster "alt" dataset, given positional coordinates (lon,lat). Requires the raster package to be installed. Essentially a wrapper for getData and extract.

Usage

elevation_correct(lon, lat, country)

Arguments

lon, lat
numeric vectors (of the same length) giving positional coordinates in units of (decimal) degrees.
country
character; the three letter ISO code for the country in which the lon,lat data were collected. See raster::getData("ISO3").

Value

A numeric vector of the same length as lon,lat of elevation values (i.e. metres above sea level).

Details

Note that raster data may need to be downloaded, and hence an internet connection will be required if these files do not already exist in the working directory.

Also note that elevation data are interpolated from the values of the four nearest raster cells. See the method argument in extract.

Examples

Run this code
## Not run: 
# data(chaingang)
# 
# # Show the original elevation profile...
# plot(elevation.m ~ distance.km, type = "l", data = chaingang)
# 
# chaingang <- transform(chaingang,
#                        elev.new = elevation_correct(lon, lat, "GBR"))
# 
# lines(elev.new ~ distance.km, col = "red", data = chaingang)
# ## End(Not run)

Run the code above in your browser using DataLab