Get elevation data for points or lines
ors_elevation(
format_in = c("geojson", "point", "polyline", "encodedpolyline", "encodedpolyline6"),
geometry,
format_out = format_in,
...,
api_key = ors_api_key(),
output = c("parsed", "text", "sf")
)
input format
longitude, latitude
coordinate pairs
output format
Optional parameters as described here
Character scalar containing openrouteservice API key
Output format. By default the response is being parsed to a list-based R object
3D point or line geometry structured according to output
:
for "text"
, a character vector of length 1 re-encoded to UTF-8.
for "parsed"
, a parsed R object.
for "sf"
, a simple features sf
object.
A GeoJSON based service to query SRTM elevation for Point or LineString 2D geometries and return 3D geometries in various formats.
# These examples might require interaction to query the local keyring, or
# might fail due to network issues, so they are not run by default
if (FALSE) { # \dontrun{
# point coordinates
coordinates <- c(13.349762, 38.11295)
try( ors_elevation("point", coordinates) )
# geojson as input
point <- '{ "type": "Point", "coordinates": [13.349762, 38.11295] }'
try( ors_elevation("geojson", point) )
# line geometry returned as encoded polyline
coordinates <- list(
c(13.349762, 38.11295),
c(12.638397, 37.645772)
)
try( ors_elevation("polyline", coordinates, format_out = "encodedpolyline") )
} # }