Learn R Programming

elevatr (version 0.1.1)

get_elev_point: Get Point Elevation

Description

Several web services provide access to point elevations. This function provides access to several of those. Currently it uses either the Mapzen Elevation Service or the USGS Elevation Point Query Service (US Only). The function accepts a data.frame of x (long) and y (lat) or a SpatialPoints/SpatialPointsDataFame as input. A SpatialPointsDataFrame is returned with elevation as an added data.frame.

Usage

get_elev_point(locations, prj = NULL, src = c("mapzen", "epqs"), api_key = get_api_key(src), ...)

Arguments

locations
Either a data.frame with x (e.g. longitude) as the first column and y (e.g. latitude) as the second column or a SpatialPoints/SpatialPointsDataFrame. Elevation for these points will be returned.
prj
A PROJ.4 string defining the projection of the locations argument. If a SpatialPoints or SpatialPointsDataFrame is provided, the PROJ.4 string will be taken from that. This argument is required for a data.frame of locations.
src
A character indicating which API to use, currently "mapzen" or "epqs". Default is "mapzen". Note that the Mapzen Elevation Service is subject to rate limits. Keyless access limits requests to 1,000 requests per day, 6 per minute, and 1 per second. With a Mapzen API key (https://mapzen.com/developers/) requests are limited to 20,000 per day or 2 per second. Per day and per second rates are not yet enforced by the elevatr package, but will be in the future. The "epqs" source is relatively slow for larger numbers of points (e.g. > 500).
api_key
A character for the appropriate API key. Default is to use key as defined in .Renviron. Acceptable environment variable name is currently only "mapzen_key".
...
Additional arguments passed to get_epqs or get_mapzen_elevation

Value

Function returns a SpatialPointsDataFrame in the projection specified by the prj argument.

Examples

Run this code
## Not run: 
# mt_wash <- data.frame(x = -71.3036, y = 44.2700)
# mt_mans <- data.frame(x = -72.8145, y = 44.5438)
# mts <- rbind(mt_wash,mt_mans)
# ll_prj <- "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"
# mts_sp <- sp::SpatialPoints(sp::coordinates(mts), 
#                             proj4string = sp::CRS(ll_prj)) 
# get_elev_point(locations = mt_wash,prj = ll_prj)
# get_elev_point(locations = mt_wash, src = "epqs", units="feet", prj = ll_prj)
# get_elev_point(locations = mt_wash, src = "epqs", units="meters", 
#                prj = ll_prj)
# get_elev_point(locations = mts_sp)
# data(sp_big)
# get_elev_point(sp_big)## End(Not run)

Run the code above in your browser using DataLab