Takes a dataframe containing coordinates (latitude and longitude) and returns the reverse geocoding query results from a specified service by using the reverse_geo function. See example usage in vignette("tidygeocoder").

This function passes all additional parameters (...) to the reverse_geo function, so you can refer to its documentation for more details on possible arguments.

reverse_geocode(
  .tbl,
  lat,
  long,
  address = "address",
  return_input = TRUE,
  limit = 1,
  return_coords = NULL,
  unique_only = FALSE,
  ...
)

Arguments

.tbl

dataframe containing coordinates

lat

latitude column name (input data). Can be quoted or unquoted (ie. lat or 'lat').

long

longitude column name (input data). Can be quoted or unquoted (ie. long or 'long').

address

address column name (output data). Can be quoted or unquoted (ie. addr or 'addr').

return_input

if TRUE then the input dataset will be combined with the geocoder query results and returned. If FALSE only the geocoder results will be returned.

limit

maximum number of results to return per input coordinate. For many geocoding services the maximum value of the limit parameter is 100. Pass limit = NULL to use the default limit value of the selected geocoding service. For batch geocoding, limit must be set to 1 (default) if return_coords = TRUE. To use limit > 1 or limit = NULL set return_input to FALSE. Refer to api_parameter_reference for more details.

return_coords

if TRUE return input coordinates. Defaults to TRUE if return_input is FALSE and FALSE if return_input is TRUE. This argument is passed to the reverse_geo() function.

unique_only

if TRUE then only unique results will be returned and return_input will be set to FALSE.

...

arguments passed to the reverse_geo function

Value

tibble (dataframe)

See also

Examples

# \donttest{ library(tibble) library(dplyr, warn.conflicts = FALSE) tibble( latitude = c(38.895865, 43.6534817), longitude = c(-77.0307713,-79.3839347) ) %>% reverse_geocode( lat = latitude, long = longitude, method = 'osm', full_results = TRUE )
#> Passing 2 coordinates to the Nominatim single coordinate geocoder
#> Query completed in: 2 seconds
#> # A tibble: 2 × 22 #> latitude longitude address place_id licence osm_type osm_id osm_lat osm_lon #> <dbl> <dbl> <chr> <int> <chr> <chr> <int> <chr> <chr> #> 1 38.9 -77.0 Freedom … 2.84e8 Data © … relation 8.06e6 38.895… -77.03… #> 2 43.7 -79.4 Toronto … 1.48e8 Data © … way 1.99e8 43.653… -79.38… #> # … with 13 more variables: tourism <chr>, house_number <chr>, road <chr>, #> # city <chr>, state <chr>, postcode <chr>, country <chr>, country_code <chr>, #> # boundingbox <list>, amenity <chr>, neighbourhood <chr>, quarter <chr>, #> # state_district <chr>
louisville %>% head(3) %>% reverse_geocode(lat = latitude, long = longitude, method = 'arcgis')
#> Passing 3 coordinates to the ArcGIS single coordinate geocoder
#> Query completed in: 1.1 seconds
#> # A tibble: 3 × 7 #> street city state zip latitude longitude address #> <chr> <chr> <chr> <dbl> <dbl> <dbl> <chr> #> 1 2722 ELLIOTT AVE Louisville Kentucky 40211 38.3 -85.8 2722 Elliott Av… #> 2 850 WASHBURN AVE Louisville Kentucky 40222 38.3 -85.6 292-302 Stone M… #> 3 1449 ST JAMES CT Louisville Kentucky 40208 38.2 -85.8 1449 Saint Jame…
louisville %>% head(2) %>% reverse_geocode(lat = latitude, long = longitude, method = 'osm', limit = 2, return_input = FALSE)
#> Passing 2 coordinates to the Nominatim single coordinate geocoder
#> Query completed in: 2 seconds
#> # A tibble: 2 × 3 #> lat long address #> <dbl> <dbl> <chr> #> 1 38.3 -85.8 2722, Elliott Avenue, Louisville, Jefferson County, Kentucky, 402… #> 2 38.3 -85.6 850, Washburn Avenue, St. Matthews, Jefferson County, Kentucky, 4…
# }