Learn R Programming

elevatr (version 0.2.0)

get_elev_point: Get Point Elevation

Description

Several web services provide access to point elevations. This function provides access to one of those. Currently it uses 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("epqs", "aws"), ...)

Arguments

locations

Either a data.frame with x (e.g. longitude) as the first column and y (e.g. latitude) as the second column, a SpatialPoints/SpatialPointsDataFrame, or a sf POINT or MULTIPOINT object. Elevation for these points will be returned in the originally supplied class.

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, either "epqs" or "aws" accepted. The "epqs" source is relatively slow for larger numbers of points (e.g. > 500). The "aws" source may be quicker in these cases provided the points are in a similar geographic area. The "aws" source downloads a DEM using get_elev_raster and then extracts the elevation for each point.

...

Additional arguments passed to get_epqs or get_aws_points. When using "aws" as the source, pay attention to the `z` argument. A defualt of 5 is used, but this uses a raster with a large ~4-5 km pixel. Additionally, the source data changes as zoom levels increase. Read https://mapzen.com/documentation/terrain-tiles/data-sources/#what-is-the-ground-resolution for details.

Value

Function returns a SpatialPointsDataFrame or sf object 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, units="feet", prj = ll_prj)
get_elev_point(locations = mt_wash, units="meters", prj = ll_prj)
get_elev_point(locations = mts_sp)
# }

Run the code above in your browser using DataLab