Skip to contents

Reverse geocodes geographic coordinates (latitude and longitude) given as numeric values. Latitudes must be between -90 and 90 and longitudes must be between -180 and 180.

Usage

reverse_geo_lite(
  lat,
  long,
  address = "address",
  full_results = FALSE,
  return_coords = TRUE,
  verbose = FALSE,
  custom_query = list()
)

Arguments

lat

latitude values (input data)

long

longitude values (input data)

address

name of the address column (in the output data)

full_results

returns all available data from the geocoding service if TRUE. If FALSE (default) then only a single address column is returned from the geocoding service.

return_coords

return input coordinates with results if TRUE. Note that most services return the input coordinates with full_results = TRUE and setting return_coords to FALSE does not prevent this.

verbose

if TRUE then detailed logs are output to the console. FALSE is default. Can be set permanently with options(tidygeocoder.verbose = TRUE)

custom_query

API-specific parameters to be used, passed as a named list (ie. list(zoom = 3)). See Details.

Value

A tibble with the results.

Details

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

Use the option custom_query = list(zoom = 3) to adjust the output. Some equivalences on terms of zoom:

zoomaddress_detail
3country
5state
8county
10city
14suburb
16major streets
17major and minor streets
18building

Examples

# \donttest{

reverse_geo_lite(lat = 40.75728, long = -73.98586)
#> # A tibble: 1 × 3
#>   address                                                              lat   lon
#>   <chr>                                                              <dbl> <dbl>
#> 1 Times Square, Broadway, Theater District, Manhattan Community Boa…  40.8 -74.0

# Several coordinates
reverse_geo_lite(
  lat = c(40.75728, 55.95335),
  long = c(-73.98586, -3.188375)
)
#> # A tibble: 2 × 3
#>   address                                                             lat    lon
#>   <chr>                                                             <dbl>  <dbl>
#> 1 Times Square, Broadway, Theater District, Manhattan Community Bo…  40.8 -74.0 
#> 2 Waverley Gate, North Bridge, Old Town, Edinburgh, City of Edinbu…  56.0  -3.19

# With options: zoom to country
reverse_geo_lite(
  lat = c(40.75728, 55.95335),
  long = c(-73.98586, -3.188375),
  custom_query = list(zoom = 0),
  verbose = TRUE,
  full_results = TRUE
)
#> # A tibble: 2 × 10
#>   address      lat     lon place_id licence osm_type osm_id country country_code
#>   <chr>      <dbl>   <dbl>    <int> <chr>   <chr>     <int> <chr>   <chr>       
#> 1 United St…  39.8 -100.     2.82e8 Data ©… relation 148838 United… us          
#> 2 United Ki…  54.7   -3.28   2.82e8 Data ©… relation  62149 United… gb          
#> # … with 1 more variable: boundingbox <list>
# }