diff --git a/CITATION.cff b/CITATION.cff index d728000f..c4f4dd1a 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -106,9 +106,6 @@ references: email: jeroen@berkeley.edu orcid: https://orcid.org/0000-0002-4035-0289 year: '2024' - identifiers: - - type: url - value: https://arxiv.org/abs/1403.2805 version: '>= 1.7.0' - type: software title: lifecycle @@ -149,6 +146,18 @@ references: year: '2024' institution: name: R Foundation for Statistical Computing +- type: software + title: arcgeocoder + abstract: 'arcgeocoder: Geocoding with the ''ArcGIS'' REST API Service' + notes: Suggests + url: https://dieghernan.github.io/arcgeocoder/ + repository: https://CRAN.R-project.org/package=arcgeocoder + authors: + - family-names: Hernangómez + given-names: Diego + email: diego.hernangomezherrero@gmail.com + orcid: https://orcid.org/0000-0001-8457-4658 + year: '2024' - type: software title: ggplot2 abstract: 'ggplot2: Create Elegant Data Visualisations Using the Grammar of Graphics' diff --git a/DESCRIPTION b/DESCRIPTION index 20e20aa6..d2d92049 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -25,6 +25,7 @@ Imports: sf (>= 0.9.0), utils Suggests: + arcgeocoder, ggplot2 (>= 3.0.0), knitr, rmarkdown, @@ -39,7 +40,7 @@ Copyright: Data © OpenStreetMap contributors, ODbL 1.0. Encoding: UTF-8 Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.0 X-schema.org-applicationCategory: cartography X-schema.org-keywords: r, geocoding, openstreetmap, address, nominatim, reverse-geocoding, rstats, shapefile, r-package, spatial, cran, diff --git a/NEWS.md b/NEWS.md index 906fa4be..06328410 100644 --- a/NEWS.md +++ b/NEWS.md @@ -8,6 +8,7 @@ - `geo_amenity()` and `geo_amenity_sf()`, see [Nominatim/issues/1311](https://github.com/osm-search/Nominatim/issues/1311). + Use `arcgeocoder::arc_geo_categories()` as an alternative. - `nominatimlite::osm_amenities` data set deleted. # nominatimlite 0.2.1 diff --git a/R/geo_amenity.R b/R/geo_amenity.R index 48a157bc..f60da235 100644 --- a/R/geo_amenity.R +++ b/R/geo_amenity.R @@ -4,7 +4,7 @@ #' `r lifecycle::badge("deprecated")` #' #' This operation is not supported any more. Use -#' [**osmdata**](https://github.com/ropensci/osmdata) instead. +#' [arcgeocoder::arc_geo_categories()] instead. #' #' #' @param bbox A numeric vector of latitude and longitude @@ -19,21 +19,30 @@ #' #' @inheritParams geo_lite #' -#' @return A \CRANpkg{tibble} with the results. +#' @return An error. #' #' @seealso [geo_amenity_sf()] -#' @details +#' @keywords internal #' -#' Bounding boxes can be located using different online tools, as -#' [Bounding Box Tool](https://boundingbox.klokantech.com/). +#' @export +#' @examples +#' \donttest{ +#' #' # Madrid, Spain #' -#' For a full list of valid amenities see -#' . +#' library(arcgeocoder) +#' library(ggplot2) #' +#' bbox <- c(-3.888954, 40.311977, -3.517916, 40.643729) #' -#' @keywords internal +#' # Food +#' rest_pub <- arc_geo_categories( +#' bbox = bbox, category = "Bakery,Bar or Pub", +#' full_results = TRUE, +#' limit = 50 +#' ) #' -#' @export +#' rest_pub +#' } geo_amenity <- function(bbox, amenity, lat = "lat", @@ -46,6 +55,7 @@ geo_amenity <- function(bbox, strict = FALSE) { if (requireNamespace("lifecycle", quietly = TRUE)) { lifecycle::deprecate_stop("0.3.0", "geo_amenity()", + with = "arcgeocoder::arc_geo_categories()", details = paste( "Operation not supported any", "more by the Nominatim API." diff --git a/R/geo_amenity_sf.R b/R/geo_amenity_sf.R index 80d2b0f1..3a755e57 100644 --- a/R/geo_amenity_sf.R +++ b/R/geo_amenity_sf.R @@ -4,27 +4,42 @@ #' `r lifecycle::badge("deprecated")` #' #' This operation is not supported any more. Use -#' [**osmdata**](https://github.com/ropensci/osmdata) instead. +#' [arcgeocoder::arc_geo_categories()] instead. #' #' #' @inheritParams geo_lite_sf #' @inheritParams geo_amenity #' -#' @return A \CRANpkg{sf} object with the results. -#' -#' @details -#' -#' Bounding boxes can be located using different online tools, as -#' [Bounding Box Tool](https://boundingbox.klokantech.com/). -#' -#' For a full list of valid amenities see -#' . +#' @return An error #' #' @inheritSection geo_lite_sf About Geometry Types #' #' @keywords internal #' #' @export +#' @examples +#' \donttest{ +#' #' # Madrid, Spain +#' +#' library(arcgeocoder) +#' library(ggplot2) +#' +#' bbox <- c(-3.888954, 40.311977, -3.517916, 40.643729) +#' +#' # Food +#' rest_pub <- arc_geo_categories( +#' bbox = bbox, category = "Bakery,Bar or Pub", +#' full_results = TRUE, +#' limit = 50 +#' ) +#' if (nrow(rest_pub) > 1) { +#' # To sf +#' rest_pub_sf <- sf::st_as_sf(rest_pub, coords = c("lon", "lat"), crs = 4326) +#' +#' ggplot(rest_pub_sf) + +#' geom_sf(aes(color = Type)) +#' } +#' } geo_amenity_sf <- function(bbox, amenity, limit = 1, @@ -36,6 +51,7 @@ geo_amenity_sf <- function(bbox, strict = FALSE) { if (requireNamespace("lifecycle", quietly = TRUE)) { lifecycle::deprecate_stop("0.3.0", "geo_amenity_sf()", + with = "arcgeocoder::arc_geo_categories()", details = paste( "Operation not supported any", "more by the Nominatim API." diff --git a/codemeta.json b/codemeta.json index 017b3ab0..b4e794f0 100644 --- a/codemeta.json +++ b/codemeta.json @@ -14,7 +14,7 @@ "name": "R", "url": "https://r-project.org" }, - "runtimePlatform": "R version 4.3.2 (2023-10-31)", + "runtimePlatform": "R version 4.3.2 (2023-10-31 ucrt)", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", @@ -57,6 +57,18 @@ } ], "softwareSuggestions": [ + { + "@type": "SoftwareApplication", + "identifier": "arcgeocoder", + "name": "arcgeocoder", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=arcgeocoder" + }, { "@type": "SoftwareApplication", "identifier": "ggplot2", @@ -187,7 +199,7 @@ }, "applicationCategory": "cartography", "keywords": ["r", "geocoding", "openstreetmap", "address", "nominatim", "reverse-geocoding", "rstats", "shapefile", "r-package", "spatial", "cran", "api-wrapper", "api", "gis"], - "fileSize": "246.956KB", + "fileSize": "251.108KB", "citation": [ { "@type": "SoftwareSourceCode", diff --git a/inst/schemaorg.json b/inst/schemaorg.json index b9266ee9..c637c64e 100644 --- a/inst/schemaorg.json +++ b/inst/schemaorg.json @@ -34,7 +34,7 @@ "name": "Comprehensive R Archive Network (CRAN)", "url": "https://cran.r-project.org" }, - "runtimePlatform": "R version 4.3.2 (2023-10-31)", + "runtimePlatform": "R version 4.3.2 (2023-10-31 ucrt)", "version": "0.2.1.9000" }, { diff --git a/man/figures/README-line-object-1.png b/man/figures/README-line-object-1.png index ae7b11fa..694e71fd 100644 Binary files a/man/figures/README-line-object-1.png and b/man/figures/README-line-object-1.png differ diff --git a/man/figures/README-pizzahut-1.png b/man/figures/README-pizzahut-1.png index 8762aafb..579a2711 100644 Binary files a/man/figures/README-pizzahut-1.png and b/man/figures/README-pizzahut-1.png differ diff --git a/man/figures/README-statue_liberty-1.png b/man/figures/README-statue_liberty-1.png index cc20636e..a9755839 100644 Binary files a/man/figures/README-statue_liberty-1.png and b/man/figures/README-statue_liberty-1.png differ diff --git a/man/geo_amenity.Rd b/man/geo_amenity.Rd index c0aeef23..1cce33da 100644 --- a/man/geo_amenity.Rd +++ b/man/geo_amenity.Rd @@ -47,20 +47,32 @@ the \code{bbox}. Note that Nominatim default behavior may return results located outside the provided bounding box.} } \value{ -A \CRANpkg{tibble} with the results. +An error. } \description{ \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} This operation is not supported any more. Use -\href{https://github.com/ropensci/osmdata}{\strong{osmdata}} instead. +\code{\link[arcgeocoder:arc_geo_categories]{arcgeocoder::arc_geo_categories()}} instead. } -\details{ -Bounding boxes can be located using different online tools, as -\href{https://boundingbox.klokantech.com/}{Bounding Box Tool}. +\examples{ +\donttest{ +#' # Madrid, Spain -For a full list of valid amenities see -\url{https://wiki.openstreetmap.org/wiki/Key:amenity}. +library(arcgeocoder) +library(ggplot2) + +bbox <- c(-3.888954, 40.311977, -3.517916, 40.643729) + +# Food +rest_pub <- arc_geo_categories( + bbox = bbox, category = "Bakery,Bar or Pub", + full_results = TRUE, + limit = 50 +) + +rest_pub +} } \seealso{ \code{\link[=geo_amenity_sf]{geo_amenity_sf()}} diff --git a/man/geo_amenity_sf.Rd b/man/geo_amenity_sf.Rd index f492c596..d56f8c99 100644 --- a/man/geo_amenity_sf.Rd +++ b/man/geo_amenity_sf.Rd @@ -47,20 +47,13 @@ the \code{bbox}. Note that Nominatim default behavior may return results located outside the provided bounding box.} } \value{ -A \CRANpkg{sf} object with the results. +An error } \description{ \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} This operation is not supported any more. Use -\href{https://github.com/ropensci/osmdata}{\strong{osmdata}} instead. -} -\details{ -Bounding boxes can be located using different online tools, as -\href{https://boundingbox.klokantech.com/}{Bounding Box Tool}. - -For a full list of valid amenities see -\url{https://wiki.openstreetmap.org/wiki/Key:amenity}. +\code{\link[arcgeocoder:arc_geo_categories]{arcgeocoder::arc_geo_categories()}} instead. } \section{About Geometry Types}{ @@ -82,4 +75,28 @@ The function is vectorized, allowing for multiple addresses to be geocoded; in case of \code{points_only = FALSE} multiple geometry types may be returned. } +\examples{ +\donttest{ +#' # Madrid, Spain + +library(arcgeocoder) +library(ggplot2) + +bbox <- c(-3.888954, 40.311977, -3.517916, 40.643729) + +# Food +rest_pub <- arc_geo_categories( + bbox = bbox, category = "Bakery,Bar or Pub", + full_results = TRUE, + limit = 50 +) +if (nrow(rest_pub) > 1) { + # To sf + rest_pub_sf <- sf::st_as_sf(rest_pub, coords = c("lon", "lat"), crs = 4326) + + ggplot(rest_pub_sf) + + geom_sf(aes(color = Type)) +} +} +} \keyword{internal} diff --git a/revdep/README.md b/revdep/README.md index ef01f427..bd56d75d 100644 --- a/revdep/README.md +++ b/revdep/README.md @@ -1,17 +1,18 @@ # Platform -|field |value | -|:--------|:---------------------------------------------------------------------| -|version |R version 4.3.2 (2023-10-31 ucrt) | -|os |Windows Server 2022 x64 (build 20348) | -|system |x86_64, mingw32 | -|ui |RTerm | -|language |(EN) | -|collate |English_United States.utf8 | -|ctype |English_United States.utf8 | -|tz |UTC | -|date |2024-01-15 | -|pandoc |2.19.2 @ C:\HOSTED~1\windows\pandoc\219~1.2\x64\PANDOC~1.2\pandoc.exe | +|field |value | +|:--------|:--------------------------------------| +|version |R version 4.3.2 (2023-10-31 ucrt) | +|os |Windows 11 x64 (build 22621) | +|system |x86_64, mingw32 | +|ui |RStudio | +|language |(EN) | +|collate |Spanish_Spain.utf8 | +|ctype |Spanish_Spain.utf8 | +|tz |Europe/Madrid | +|date |2024-01-17 | +|rstudio |2023.12.0+369 Ocean Storm (desktop) | +|pandoc |2.19.2 @ C:\PROGRA~1\Pandoc\pandoc.exe | # Dependencies @@ -42,7 +43,7 @@ |units |0.8-5 |0.8-5 | | |utf8 |1.2.4 |1.2.4 | | |vctrs |0.6.5 |0.6.5 | | -|withr |2.5.2 |2.5.2 | | +|withr |3.0.0 |3.0.0 | | |wk |0.9.1 |0.9.1 | | # Revdeps diff --git a/revdep/cran.md b/revdep/cran.md index 62d1ce49..782ef684 100644 --- a/revdep/cran.md +++ b/revdep/cran.md @@ -1,6 +1,6 @@ ## revdepcheck results -We checked 1 reverse dependencies (0 from CRAN + 1 from Bioconductor), comparing R CMD check results across CRAN and dev versions of this package. +We checked 1 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package. * We saw 0 new problems * We failed to check 0 packages diff --git a/tests/testthat/_snaps/geo_amenity.md b/tests/testthat/_snaps/geo_amenity.md index 5264cbf6..41c14fd1 100644 --- a/tests/testthat/_snaps/geo_amenity.md +++ b/tests/testthat/_snaps/geo_amenity.md @@ -5,5 +5,6 @@ Condition Error: ! `geo_amenity()` was deprecated in nominatimlite 0.3.0 and is now defunct. + i Please use `arcgeocoder::arc_geo_categories()` instead. i Operation not supported any more by the Nominatim API. diff --git a/tests/testthat/_snaps/geo_amenity_sf.md b/tests/testthat/_snaps/geo_amenity_sf.md index 5139302d..f2fd7c8b 100644 --- a/tests/testthat/_snaps/geo_amenity_sf.md +++ b/tests/testthat/_snaps/geo_amenity_sf.md @@ -5,5 +5,6 @@ Condition Error: ! `geo_amenity_sf()` was deprecated in nominatimlite 0.3.0 and is now defunct. + i Please use `arcgeocoder::arc_geo_categories()` instead. i Operation not supported any more by the Nominatim API. diff --git a/vignettes/nominatimlite.Rmd b/vignettes/nominatimlite.Rmd index 5f937b54..f6f5512f 100644 --- a/vignettes/nominatimlite.Rmd +++ b/vignettes/nominatimlite.Rmd @@ -1,157 +1,157 @@ ---- -title: "Get started with nominatimlite" -output: rmarkdown::html_vignette -desc: > - Quick examples showing what `nominatimlite` can do for you. -vignette: > - %\VignetteIndexEntry{Get started with nominatimlite} - %\VignetteEngine{knitr::rmarkdown} - %\VignetteEncoding{UTF-8} -bibliography: references.bib -link-citations: true ---- - - - - - -The goal of `nominatimlite` is to provide a light interface for geocoding -addresses, based on the [Nominatim -API](https://nominatim.org/release-docs/latest/). **Nominatim** is a tool to -search [OpenStreetMap](https://www.openstreetmap.org/) data by name and address -([geocoding](https://wiki.openstreetmap.org/wiki/Geocoding "Geocoding")) and to -generate synthetic addresses of OSM points (reverse geocoding). - -It also allows to load spatial objects using the `sf` package. - -Full site with examples and vignettes on - - -## Why `nominatimlite`? - -The main goal of `nominatimlite` is to access the Nominatim API avoiding the -dependency on `curl`. In some situations, `curl` may not be available or -accessible, so `nominatimlite` uses base functions to overcome this limitation. - -## Recommended packages - -There are other packages much more complete and mature than `nominatimlite`, -that presents similar features: - -- [`tidygeocoder`](https://jessecambon.github.io/tidygeocoder/) - [@R-tidygeocoder]. Allows to interface with Nominatim, Google, TomTom, - Mapbox, etc. for geocoding and reverse geocoding. -- [`osmdata`](https://docs.ropensci.org/osmdata/) [@R-osmdata]. Great for - downloading spatial data from OpenStreetMap, via the [Overpass - API](https://wiki.openstreetmap.org/wiki/Overpass_API). - -## Usage - -### `sf` objects - -With `nominatimlite` you can extract spatial objects easily: - - -```r -library(nominatimlite) - -# Extract some points - Pizza Hut in California - -CA <- geo_lite_sf("California", points_only = FALSE) - -pizzahut <- geo_lite_sf("Pizza Hut, California", - limit = 50, - custom_query = list(countrycodes = "us") -) - -library(ggplot2) - -ggplot(CA) + - geom_sf() + - geom_sf(data = pizzahut, col = "red") -``` - -![Pizza Hut in California](../man/figures/README-pizzahut-1.png){width="100%"} - -You can also extract polygon and line objects (if available) using the option -`points_only = FALSE`: - - -```r -sol_poly <- geo_lite_sf("Statue of Liberty, NY, USA", points_only = FALSE) - -ggplot(sol_poly) + - geom_sf() -``` - -![The Statue of -Liberty](../man/figures/README-statue_liberty-1.png){width="100%"} - -### Geocoding and reverse geocoding - -*Note: examples adapted from `tidygeocoder` package* - -In this first example we will geocode a few addresses using the `geo_lite()` -function: - - -```r -library(tibble) - -# create a dataframe with addresses -some_addresses <- tribble( - ~name, ~addr, - "White House", "1600 Pennsylvania Ave NW, Washington, DC", - "Transamerica Pyramid", "600 Montgomery St, San Francisco, CA 94111", - "Willis Tower", "233 S Wacker Dr, Chicago, IL 60606" -) - -# geocode the addresses -lat_longs <- geo_lite(some_addresses$addr, lat = "latitude", long = "longitude") -#> | | | 0% | |================= | 33% | |================================= | 67% | |==================================================| 100% -``` - -Only latitude and longitude are returned from the geocoder service in this -example, but `full_results = TRUE` can be used to return all of the data from -the geocoder service. - - - -|query | latitude| longitude|address | -|:------------------------------------------|--------:|----------:|:-----------------------------------------------------------------------------------------------------------------| -|1600 Pennsylvania Ave NW, Washington, DC | 38.89770| -77.03655|White House, 1600, Pennsylvania Avenue Northwest, Ward 2, Washington, District of Columbia, 20500, United States | -|600 Montgomery St, San Francisco, CA 94111 | 37.79520| -122.40279|Transamerica Pyramid, 600, Montgomery Street, Financial District, San Francisco, California, 94111, United States | -|233 S Wacker Dr, Chicago, IL 60606 | 41.87874| -87.63596|Willis Tower, 233, South Wacker Drive, Printer's Row, Loop, Chicago, Cook County, Illinois, 60606, United States | - - - -To perform reverse geocoding (obtaining addresses from geographic coordinates), -we can use the `reverse_geo_lite()` function. The arguments are similar to the -`geo_lite()` function, but now we specify the input data columns with the `lat` -and `long` arguments. The dataset used here is from the geocoder query above. -The single line address is returned in a column named by the `address`. - - -```r -reverse <- reverse_geo_lite( - lat = lat_longs$latitude, long = lat_longs$longitude, - address = "address_found" -) -#> | | | 0% | |================= | 33% | |================================= | 67% | |==================================================| 100% -``` - - - -|address_found | lat| lon| -|:-----------------------------------------------------------------------------------------------------------------|--------:|----------:| -|White House, 1600, Pennsylvania Avenue Northwest, Ward 2, Washington, District of Columbia, 20500, United States | 38.89770| -77.03655| -|Transamerica Pyramid, 600, Montgomery Street, Financial District, San Francisco, California, 94111, United States | 37.79520| -122.40279| -|Willis Tower, 233, South Wacker Drive, Printer's Row, Loop, Chicago, Cook County, Illinois, 60606, United States | 41.87874| -87.63596| - - - -For more advance users, see [Nominatim -docs](https://nominatim.org/release-docs/latest/api/Search/) to check the -parameters available. - -## References +--- +title: "Get started with nominatimlite" +output: rmarkdown::html_vignette +desc: > + Quick examples showing what `nominatimlite` can do for you. +vignette: > + %\VignetteIndexEntry{Get started with nominatimlite} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +bibliography: references.bib +link-citations: true +--- + + + + + +The goal of `nominatimlite` is to provide a light interface for geocoding +addresses, based on the [Nominatim +API](https://nominatim.org/release-docs/latest/). **Nominatim** is a tool to +search [OpenStreetMap](https://www.openstreetmap.org/) data by name and address +([geocoding](https://wiki.openstreetmap.org/wiki/Geocoding "Geocoding")) and to +generate synthetic addresses of OSM points (reverse geocoding). + +It also allows to load spatial objects using the `sf` package. + +Full site with examples and vignettes on + + +## Why `nominatimlite`? + +The main goal of `nominatimlite` is to access the Nominatim API avoiding the +dependency on `curl`. In some situations, `curl` may not be available or +accessible, so `nominatimlite` uses base functions to overcome this limitation. + +## Recommended packages + +There are other packages much more complete and mature than `nominatimlite`, +that presents similar features: + +- [`tidygeocoder`](https://jessecambon.github.io/tidygeocoder/) + [@R-tidygeocoder]. Allows to interface with Nominatim, Google, TomTom, + Mapbox, etc. for geocoding and reverse geocoding. +- [`osmdata`](https://docs.ropensci.org/osmdata/) [@R-osmdata]. Great for + downloading spatial data from OpenStreetMap, via the [Overpass + API](https://wiki.openstreetmap.org/wiki/Overpass_API). + +## Usage + +### `sf` objects + +With `nominatimlite` you can extract spatial objects easily: + + +```r +library(nominatimlite) + +# Extract some points - Pizza Hut in California + +CA <- geo_lite_sf("California", points_only = FALSE) + +pizzahut <- geo_lite_sf("Pizza Hut, California", + limit = 50, + custom_query = list(countrycodes = "us") +) + +library(ggplot2) + +ggplot(CA) + + geom_sf() + + geom_sf(data = pizzahut, col = "red") +``` + +![Pizza Hut in California](../man/figures/README-pizzahut-1.png){width="100%"} + +You can also extract polygon and line objects (if available) using the option +`points_only = FALSE`: + + +```r +sol_poly <- geo_lite_sf("Statue of Liberty, NY, USA", points_only = FALSE) + +ggplot(sol_poly) + + geom_sf() +``` + +![The Statue of +Liberty](../man/figures/README-statue_liberty-1.png){width="100%"} + +### Geocoding and reverse geocoding + +*Note: examples adapted from `tidygeocoder` package* + +In this first example we will geocode a few addresses using the `geo_lite()` +function: + + +```r +library(tibble) + +# create a dataframe with addresses +some_addresses <- tribble( + ~name, ~addr, + "White House", "1600 Pennsylvania Ave NW, Washington, DC", + "Transamerica Pyramid", "600 Montgomery St, San Francisco, CA 94111", + "Willis Tower", "233 S Wacker Dr, Chicago, IL 60606" +) + +# geocode the addresses +lat_longs <- geo_lite(some_addresses$addr, lat = "latitude", long = "longitude") +#> | | | 0% | |================= | 33% | |================================= | 67% | |==================================================| 100% +``` + +Only latitude and longitude are returned from the geocoder service in this +example, but `full_results = TRUE` can be used to return all of the data from +the geocoder service. + + + +|query | latitude| longitude|address | +|:------------------------------------------|--------:|----------:|:-----------------------------------------------------------------------------------------------------------------| +|1600 Pennsylvania Ave NW, Washington, DC | 38.89770| -77.03655|White House, 1600, Pennsylvania Avenue Northwest, Ward 2, Washington, District of Columbia, 20500, United States | +|600 Montgomery St, San Francisco, CA 94111 | 37.79520| -122.40279|Transamerica Pyramid, 600, Montgomery Street, Financial District, San Francisco, California, 94111, United States | +|233 S Wacker Dr, Chicago, IL 60606 | 41.87874| -87.63596|Willis Tower, 233, South Wacker Drive, Printer's Row, Loop, Chicago, Cook County, Illinois, 60606, United States | + + + +To perform reverse geocoding (obtaining addresses from geographic coordinates), +we can use the `reverse_geo_lite()` function. The arguments are similar to the +`geo_lite()` function, but now we specify the input data columns with the `lat` +and `long` arguments. The dataset used here is from the geocoder query above. +The single line address is returned in a column named by the `address`. + + +```r +reverse <- reverse_geo_lite( + lat = lat_longs$latitude, long = lat_longs$longitude, + address = "address_found" +) +#> | | | 0% | |================= | 33% | |================================= | 67% | |==================================================| 100% +``` + + + +|address_found | lat| lon| +|:-----------------------------------------------------------------------------------------------------------------|--------:|----------:| +|White House, 1600, Pennsylvania Avenue Northwest, Ward 2, Washington, District of Columbia, 20500, United States | 38.89770| -77.03655| +|Transamerica Pyramid, 600, Montgomery Street, Financial District, San Francisco, California, 94111, United States | 37.79520| -122.40279| +|Willis Tower, 233, South Wacker Drive, Printer's Row, Loop, Chicago, Cook County, Illinois, 60606, United States | 41.87874| -87.63596| + + + +For more advance users, see [Nominatim +docs](https://nominatim.org/release-docs/latest/api/Search/) to check the +parameters available. + +## References