ors_geocode: Openrouteservice Geocoding

View source: R/geocode.R

ors_geocodeR Documentation

Openrouteservice Geocoding

Description

Resolve input coordinates to addresses and vice versa.

Usage

ors_geocode(
  query,
  location,
  ...,
  api_key = ors_api_key(),
  output = c("parsed", "text", "sf")
)

Arguments

query

Name of location, street address or postal code. For a structured geocoding request a named list of parameters.

location

Coordinates to be inquired provided in the form c(longitude, latitude)

...

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

Details

This endpoint can be used for geocoding (specified query) and reverse geocoding requests (specified location). Either query or location has to be specified for a valid request. If both parameters are specified location takes precedence.

Value

Geocoding: a JSON formatted list of objects corresponding to the search input. Reverse geocoding: the next enclosing object with an address tag which surrounds the given coordinate.

Author(s)

Andrzej Oleś andrzej.oles@gmail.com

Examples

## locations of Heidelberg around the globe
x <- ors_geocode("Heidelberg")

## set the number of results returned
x <- ors_geocode("Heidelberg", size = 1)

## search within a particular country
ors_geocode("Heidelberg", boundary.country = "DE")

## structured geocoding
x <- ors_geocode(list(locality="Heidelberg", county="Heidelberg"))

## reverse geocoding
location <- x$features[[1L]]$geometry$coordinates
y <- ors_geocode(location = location, layers = "locality", size = 1)

openrouteservice documentation built on Oct. 21, 2024, 9:06 a.m.