Resolve input coordinates to addresses and vice versa.

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

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.

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.

Author

Andrzej Oleś andrzej@openrouteservice.org

Examples

## locations of Heidelberg around the globe x = ors_geocode("Heidelberg") ## set the number of results returne x = ors_geocode("Heidelberg", size = 1) ## search within a particular country ors_geocode("Heidelberg", boundary.country = "DE")
#> <ors_geocode> #> List of 4 #> $ geocoding:List of 6 #> ..$ version : chr "0.2" #> ..$ attribution: chr "https://openrouteservice.org/terms-of-service/#attribution-geocode" #> ..$ query :List of 9 #> .. ..$ text : chr "Heidelberg" #> .. ..$ size : int 10 #> .. ..$ layers : chr [1:20] "venue" "street" "country" "macroregion" ... #> .. ..$ private : logi FALSE #> .. ..$ boundary.country: chr "DEU" #> .. ..$ lang :List of 5 #> .. .. ..$ name : chr "English" #> .. .. ..$ iso6391 : chr "en" #> .. .. ..$ iso6393 : chr "eng" #> .. .. ..$ via : chr "default" #> .. .. ..$ defaulted: logi TRUE #> .. .. [list output truncated] #> ..$ warnings : chr "performance optimization: excluding 'address' layer" #> ..$ engine :List of 3 #> .. ..$ name : chr "Pelias" #> .. ..$ author : chr "Mapzen" #> .. ..$ version: chr "1.0" #> ..$ timestamp : num 1.63e+12 #> $ type : chr "FeatureCollection" #> $ features :List of 4 #> ..$ :List of 4 #> .. ..$ type : chr "Feature" #> .. ..$ geometry :List of 2 #> .. .. ..$ type : chr "Point" #> .. .. ..$ coordinates: num [1:2] 8.77 49.38 #> .. ..$ properties:List of 27 #> .. .. ..$ id : chr "101906011" #> .. .. ..$ gid : chr "whosonfirst:locality:101906011" #> .. .. ..$ layer : chr "locality" #> .. .. ..$ source : chr "whosonfirst" #> .. .. ..$ source_id : chr "101906011" #> .. .. ..$ name : chr "Heidelberg" #> .. .. .. [list output truncated] #> .. ..$ bbox : num [1:4] 8.57 49.35 8.79 49.46 #> ..$ :List of 4 #> .. ..$ type : chr "Feature" #> .. ..$ geometry :List of 2 #> .. .. ..$ type : chr "Point" #> .. .. ..$ coordinates: num [1:2] 8.69 49.4 #> .. ..$ properties:List of 25 #> .. .. ..$ id : chr "1377688433" #> .. .. ..$ gid : chr "whosonfirst:localadmin:1377688433" #> .. .. ..$ layer : chr "localadmin" #> .. .. ..$ source : chr "whosonfirst" #> .. .. ..$ source_id : chr "1377688433" #> .. .. ..$ name : chr "Heidelberg" #> .. .. .. [list output truncated] #> .. ..$ bbox : num [1:4] 8.57 49.35 8.79 49.46 #> ..$ :List of 4 #> .. ..$ type : chr "Feature" #> .. ..$ geometry :List of 2 #> .. .. ..$ type : chr "Point" #> .. .. ..$ coordinates: num [1:2] 12.3 53.1 #> .. ..$ properties:List of 27 #> .. .. ..$ id : chr "1393562915" #> .. .. ..$ gid : chr "whosonfirst:neighbourhood:1393562915" #> .. .. ..$ layer : chr "neighbourhood" #> .. .. ..$ source : chr "whosonfirst" #> .. .. ..$ source_id : chr "1393562915" #> .. .. ..$ name : chr "Heidelberg" #> .. .. .. [list output truncated] #> .. ..$ bbox : num [1:4] 12.3 53.1 12.3 53.1 #> ..$ :List of 4 #> .. ..$ type : chr "Feature" #> .. ..$ geometry :List of 2 #> .. .. ..$ type : chr "Point" #> .. .. ..$ coordinates: num [1:2] 13.5 50.6 #> .. ..$ properties:List of 27 #> .. .. ..$ id : chr "1393558913" #> .. .. ..$ gid : chr "whosonfirst:neighbourhood:1393558913" #> .. .. ..$ layer : chr "neighbourhood" #> .. .. ..$ source : chr "whosonfirst" #> .. .. ..$ source_id : chr "1393558913" #> .. .. ..$ name : chr "Heidelberg" #> .. .. .. [list output truncated] #> .. ..$ bbox : num [1:4] 13.5 50.6 13.5 50.6 #> $ bbox : num [1:4] 8.57 49.35 13.48 53.1
## 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)