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")
)

Arguments

format_in

input format

geometry

longitude, latitude coordinate pairs

format_out

output format

...

Optional parameters as described here

api_key

Character scalar containing openrouteservice API key

output

Output format. By default the response is being parsed to a list-based R object

Value

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.

Details

A GeoJSON based service to query SRTM elevation for Point or LineString 2D geometries and return 3D geometries in various formats.

Author

Andrzej Oleś andrzej@openrouteservice.org

Examples

# point coordinates coordinates <- c(13.349762, 38.11295) ors_elevation("point", coordinates)
#> <ors_elevation> #> num [1:3] 13.3 38.1 38
# geojson as input point <- '{ "type": "Point", "coordinates": [13.349762, 38.11295] }' ors_elevation("geojson", point)
#> <ors_elevation> #> List of 2 #> $ coordinates: num [1:3] 13.3 38.1 38 #> $ type : chr "Point"
# line geometry returned as encoded polyline coordinates <- list( c(13.349762, 38.11295), c(12.638397, 37.645772) ) ors_elevation("polyline", coordinates, format_out = "encodedpolyline")
#> <ors_elevation> #> chr "}|rgF_knpAolFzfzA~|iCf{C"