Learn R Programming

rgbif (version 0.7.0)

elevation: Get elevation for lat/long points from a data.frame or list of points.

Description

Get elevation for lat/long points from a data.frame or list of points.

Usage

elevation(input = NULL, latitude = NULL, longitude = NULL,
  latlong = NULL, callopts = list())

Arguments

input
A data.frame of lat/long data. There must be columns decimalLatitude and decimalLongitude.
latitude
A vector of latitude's. Must be the same length as the longitude vector.
longitude
A vector of longitude's. Must be the same length as the latitude vector.
latlong
A vector of lat/long pairs. See examples.
callopts
Options passed on to httr::GET, like curl options for debugging.

Value

  • A new column named elevation in the supplied data.frame or a vector with elevation of each location in meters.

References

Uses the Google Elevation API at the following link https://developers.google.com/maps/documentation/elevation/

Examples

Run this code
key <- name_suggest('Puma concolor')$key[1]
dat <- occ_search(taxonKey=key, return='data', limit=300, hasCoordinate=TRUE)
elevation(dat)

# Pass in a vector of lat's and a vector of long's
elevation(latitude=dat$decimalLatitude, longitude=dat$decimalLongitude)

# Pass in lat/long pairs in a single vector
pairs <- list(c(31.8496,-110.576060), c(29.15503,-103.59828))
elevation(latlong=pairs)

Run the code above in your browser using DataLab