get_elev_point {elevatr} | R Documentation |
This function provides access to point elevations using either the USGS
Elevation Point Query Service (US Only) or by extracting point elevations
from the AWS Terrain Tiles. 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
.
get_elev_point(
locations,
prj = NULL,
src = c("epqs", "aws"),
overwrite = FALSE,
...
)
locations |
Either a |
prj |
A string defining the projection of the locations argument. The
string needs to be an acceptable SRS_string for
|
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 |
overwrite |
A logical indicating that existing |
... |
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://github.com/tilezen/joerd/blob/master/docs/data-sources.md#what-is-the-ground-resolution for details. |
Function returns a SpatialPointsDataFrame
or sf
object
in the projection specified by the prj
argument.
## 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 <- "EPSG:4326"
mts_sp <- sp::SpatialPoints(sp::coordinates(mts),
proj4string = sp::CRS(SRS_string = ll_prj))
mts_spdf <- sp::SpatialPointsDataFrame(mts_sp,
data = data.frame(name =
c("Mt. Washington", "Mt. Mansfield")))
mts_raster <- raster::raster(mts_sp, ncol = 2, nrow = 2)
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)
get_elev_point(locations = mts_spdf)
get_elev_point(locations = mts_raster)
# Code to split into a loop and grab point at a time.
# This is usually faster for points that are spread apart
library(dplyr)
elev <- vector("numeric", length = nrow(mts))
pb <- progress_estimated(length(elev))
for(i in seq_along(mts)){
pb$tick()$print()
elev[i]<-suppressMessages(get_elev_point(locations = mts[i,], prj = ll_prj,
src = "aws", z = 14)$elevation)
}
mts_elev <- cbind(mts, elev)
mts_elev
## End(Not run)