Skip to contents

Looks up addresses and other details for one or more OpenStreetMap (OSM) objects, such as nodes, ways or relations. Results are returned as a tibble. Use geo_address_lookup_sf() to return an sf object instead.

Usage

geo_address_lookup(
  osm_ids,
  type = c("N", "W", "R"),
  lat = "lat",
  long = "lon",
  full_results = FALSE,
  return_addresses = TRUE,
  verbose = FALSE,
  nominatim_server = "https://nominatim.openstreetmap.org/",
  custom_query = list()
)

Arguments

osm_ids

A numeric vector of OSM identifiers, for example c(12345, 67890).

type

A character vector containing the OSM object type associated with each value in osm_ids. Possible values are node ("N"), way ("W") and relation ("R"). A single value is recycled.

lat

A string giving the name of the latitude column in the output. Defaults to "lat".

long

A string giving the name of the longitude column in the output. Defaults to "lon".

full_results

If TRUE, return all available fields from the Nominatim API. If FALSE, return only query metadata, location data and requested address columns.

return_addresses

If TRUE, include single-line addresses in the results.

verbose

If TRUE, displays detailed messages in the console.

nominatim_server

A string giving the base URL of the Nominatim server. Defaults to "https://nominatim.openstreetmap.org/".

custom_query

A named list of additional API parameters, for example list(countrycodes = "US"). See Details.

Value

A tibble with the results that match the query.

Details

See https://nominatim.org/release-docs/latest/api/Lookup/ for additional parameters to be passed to custom_query.

Examples

# \donttest{
ids <- geo_address_lookup(osm_ids = c(46240148, 34633854), type = "W")

ids
#> # A tibble: 2 × 4
#>   query       lat   lon address                                                 
#>   <chr>     <dbl> <dbl> <chr>                                                   
#> 1 W46240148  40.8 -73.9 5th Avenue, Harlem, Manhattan Community Board 11, Manha…
#> 2 W34633854  40.7 -74.0 Empire State Building, 350, 5th Avenue, Koreatown, Manh…

several <- geo_address_lookup(c(146656, 240109189), type = c("R", "N"))
several
#> # A tibble: 2 × 4
#>   query        lat   lon address                                                
#>   <chr>      <dbl> <dbl> <chr>                                                  
#> 1 R146656     53.4 -2.23 Manchester, Greater Manchester, England, United Kingdom
#> 2 N240109189  52.5 13.4  Berlin, Deutschland                                    
# }