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,
...
)
dataframe containing coordinates
latitude column name (input data). Can be quoted or unquoted (ie. lat or 'lat').
longitude column name (input data). Can be quoted or unquoted (ie. long or 'long').
address column name (output data). Can be quoted or unquoted (ie. addr or 'addr').
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.
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.
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.
if TRUE then only unique results will be returned and return_input will be set to FALSE.
arguments passed to the reverse_geo function
tibble (dataframe)
# \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 × 23
#> latit…¹ longi…² address place…³ licence osm_t…⁴ osm_id osm_lat osm_lon tourism
#> <dbl> <dbl> <chr> <int> <chr> <chr> <int> <chr> <chr> <chr>
#> 1 38.9 -77.0 L’Enfa… 2.75e8 Data ©… way 9.00e8 38.895… -77.03… L’Enfa…
#> 2 43.7 -79.4 Toront… 1.53e8 Data ©… way 1.99e8 43.653… -79.38… NA
#> # … with 13 more variables: road <chr>, city <chr>, state <chr>,
#> # `ISO3166-2-lvl4` <chr>, postcode <chr>, country <chr>, country_code <chr>,
#> # boundingbox <list>, amenity <chr>, house_number <chr>, neighbourhood <chr>,
#> # quarter <chr>, state_district <chr>, and abbreviated variable names
#> # ¹latitude, ²longitude, ³place_id, ⁴osm_type
louisville %>%
head(3) %>%
reverse_geocode(
lat = latitude, long = longitude,
method = "arcgis"
)
#> Passing 3 coordinates to the ArcGIS single coordinate geocoder
#> Query completed in: 1.2 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 274-288 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, Russell, Louisville, Jefferson County, Kent…
#> 2 38.3 -85.6 850, Washburn Avenue, St. Matthews, Jefferson County, Kentucky, 4…
# }