Generates an address from a latitude and longitude. Latitudes must be
between [-90, 90]
and longitudes between [-180, 180]
. This
function returns the tibble associated with the query, see
reverse_geo_lite_sf()
for retrieving the data as a spatial object
(sf) format).
Usage
reverse_geo_lite(
lat,
long,
address = "address",
full_results = FALSE,
return_coords = TRUE,
verbose = FALSE,
nominatim_server = "https://nominatim.openstreetmap.org/",
progressbar = TRUE,
custom_query = list()
)
Arguments
- lat
latitude values in numeric format. Must be in the range
[-90, 90]
.- long
longitude values in numeric format. Must be in the range
[-180, 180]
.- address
address column name in the output data (default
"address"
).- full_results
returns all available data from the API service. If
FALSE
(default) only latitude, longitude and address columns are returned. See alsoreturn_addresses
.- return_coords
return input coordinates with results if
TRUE
.- verbose
if
TRUE
then detailed logs are output to the console.- nominatim_server
The URL of the Nominatim server to use. Defaults to
"https://nominatim.openstreetmap.org/"
.- progressbar
Logical. If
TRUE
displays a progress bar to indicate the progress of the function.- 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
.
About Zooming
Use the option custom_query = list(zoom = 3)
to adjust the output. Some
equivalences on terms of zoom:
zoom | address_detail |
3 | country |
5 | state |
8 | county |
10 | city |
14 | suburb |
16 | major streets |
17 | major and minor streets |
18 | building |
See also
reverse_geo_lite_sf()
, tidygeocoder::reverse_geo()
Reverse geocoding coordinates:
reverse_geo_lite_sf()
Examples
# \donttest{
reverse_geo_lite(lat = 40.75728, long = -73.98586)
#> # A tibble: 1 × 3
#> address lat lon
#> <chr> <dbl> <dbl>
#> 1 Times Square, 7th Avenue, Manhattan Community Board 5, Manhattan,… 40.8 -74.0
# Several coordinates
reverse_geo_lite(lat = c(40.75728, 55.95335), long = c(-73.98586, -3.188375))
#>
|
| | 0%
|
|========================= | 50%
|
|==================================================| 100%
#> # A tibble: 2 × 3
#> address lat lon
#> <chr> <dbl> <dbl>
#> 1 Times Square, 7th Avenue, Manhattan Community Board 5, Manhattan… 40.8 -74.0
#> 2 Edinburgh Distance Marker, Waterloo Place, Greenside, New Town/B… 56.0 -3.19
# With options: zoom to country level
sev <- reverse_geo_lite(
lat = c(40.75728, 55.95335), long = c(-73.98586, -3.188375),
custom_query = list(zoom = 0, extratags = 1),
verbose = TRUE, full_results = TRUE
)
#>
|
| | 0%
|
|========================= | 50%
|
|==================================================| 100%
dplyr::glimpse(sev)
#> Rows: 2
#> Columns: 47
#> $ address <chr> "United States", "United Kingdom"
#> $ lat <dbl> 39.78373, 54.70235
#> $ lon <dbl> -100.445882, -3.276575
#> $ place_id <int> 77249893, 269356315
#> $ licence <chr> "Data © OpenStreetMap contributors, ODb…
#> $ osm_type <chr> "relation", "relation"
#> $ osm_id <int> 148838, 62149
#> $ class <chr> "boundary", "boundary"
#> $ type <chr> "administrative", "administrative"
#> $ place_rank <int> 4, 4
#> $ importance <dbl> 0.9356914, 0.8723780
#> $ addresstype <chr> "country", "country"
#> $ name <chr> "United States", "United Kingdom"
#> $ country <chr> "United States", "United Kingdom"
#> $ country_code <chr> "us", "gb"
#> $ flag <chr> "https://upload.wikimedia.org/wikipedia…
#> $ sqkm <chr> "9826675", "243610"
#> $ wikidata <chr> "Q30", "Q145"
#> $ wikipedia <chr> "en:United States", "en:United Kingdom"
#> $ population <chr> "331449281", "61792000"
#> $ border_type <chr> "national", NA
#> $ capital_city <chr> "Washington DC", NA
#> $ linked_place <chr> "country", "country"
#> $ `contact:website` <chr> "https://www.usa.gov", NA
#> $ `population:date` <chr> "2020", NA
#> $ `ISO3166-1:alpha2` <chr> "US", "GB"
#> $ `ISO3166-1:alpha3` <chr> "USA", "GBR"
#> $ default_language <chr> "en", "en"
#> $ `ISO3166-1:numeric` <chr> "840", "826"
#> $ `alt_short_name:en` <chr> "US", NA
#> $ `alt_short_name:pl` <chr> "St. Zj.", NA
#> $ country_code_fips <chr> "US", NA
#> $ `old_short_name:ru` <chr> "САСШ", NA
#> $ `source:population` <chr> "census.gov", "http://www.statistics.go…
#> $ `not:official_name:vi` <chr> "Hợp chủng quốc Hoa Kỳ;Hợp chúng quốc H…
#> $ country_code_iso3166_1_alpha_2 <chr> "US", NA
#> $ boundingbox <list> <-14.76084, 71.58895, -180.00000, 180.0…
#> $ `ref:gss` <chr> NA, "K02000001"
#> $ currency <chr> NA, "GBP"
#> $ timezone <chr> NA, "Europe/London"
#> $ native_name <chr> NA, "United Kingdom of Great Britain an…
#> $ `source:sqkm` <chr> NA, "CIA World Factbook"
#> $ driving_side <chr> NA, "left"
#> $ `native_name:da` <chr> NA, "Det Forenede Kongerige Storbritann…
#> $ `native_name:es` <chr> NA, "Reino Unido de Gran Bretaña e Irla…
#> $ `native_name:vi` <chr> NA, "Vương quốc Liên hiệp Anh và Bắc Ir…
#> $ `source:ref:gss` <chr> NA, "ONS_OpenData"
# }