diff --git a/CITATION.cff b/CITATION.cff
index 8fa69bd0..d728000f 100644
--- a/CITATION.cff
+++ b/CITATION.cff
@@ -11,8 +11,8 @@ title: 'nominatimlite: Interface with ''Nominatim'' API Service'
version: 0.2.1.9000
doi: 10.5281/zenodo.5113195
abstract: Lite interface for getting data from 'OSM' service 'Nominatim' .
- Extract coordinates from addresses, find places near a set of coordinates, search
- for amenities and return spatial objects on 'sf' format.
+ Extract coordinates from addresses, find places near a set of coordinates and return
+ spatial objects on 'sf' format.
authors:
- family-names: Hernangómez
given-names: Diego
@@ -31,8 +31,8 @@ preferred-citation:
doi: 10.5281/zenodo.5113195
url: https://dieghernan.github.io/nominatimlite/
abstract: Lite interface for getting data from OSM service Nominatim .
- Extract coordinates from addresses, find places near a set of coordinates, search
- for amenities and return spatial objects on sf format.
+ Extract coordinates from addresses, find places near a set of coordinates and
+ return spatial objects on sf format.
repository: https://CRAN.R-project.org/package=nominatimlite
repository-code: https://github.com/dieghernan/nominatimlite
url: https://dieghernan.github.io/nominatimlite/
@@ -110,6 +110,21 @@ references:
- type: url
value: https://arxiv.org/abs/1403.2805
version: '>= 1.7.0'
+- type: software
+ title: lifecycle
+ abstract: 'lifecycle: Manage the Life Cycle of your Package Functions'
+ notes: Imports
+ url: https://lifecycle.r-lib.org/
+ repository: https://CRAN.R-project.org/package=lifecycle
+ authors:
+ - family-names: Henry
+ given-names: Lionel
+ email: lionel@posit.co
+ - family-names: Wickham
+ given-names: Hadley
+ email: hadley@posit.co
+ orcid: https://orcid.org/0000-0003-4757-117X
+ year: '2024'
- type: software
title: sf
abstract: 'sf: Simple Features for R'
diff --git a/DESCRIPTION b/DESCRIPTION
index bf2e2c09..20e20aa6 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -10,8 +10,8 @@ Authors@R: c(
)
Description: Lite interface for getting data from 'OSM' service
'Nominatim' . Extract
- coordinates from addresses, find places near a set of coordinates,
- search for amenities and return spatial objects on 'sf' format.
+ coordinates from addresses, find places near a set of coordinates and
+ return spatial objects on 'sf' format.
License: MIT + file LICENSE
URL: https://dieghernan.github.io/nominatimlite/,
https://github.com/dieghernan/nominatimlite
@@ -21,6 +21,7 @@ Depends:
Imports:
dplyr (>= 1.0.0),
jsonlite (>= 1.7.0),
+ lifecycle,
sf (>= 0.9.0),
utils
Suggests:
@@ -37,7 +38,6 @@ Config/testthat/parallel: true
Copyright: Data © OpenStreetMap contributors, ODbL 1.0.
Encoding: UTF-8
-LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
X-schema.org-applicationCategory: cartography
diff --git a/NEWS.md b/NEWS.md
index cb231632..906fa4be 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -4,6 +4,12 @@
`reverse_geo_lite()` and `reverse_geo_lite_sf()` to display progress in the
console.
+## Deprecated
+
+- `geo_amenity()` and `geo_amenity_sf()`, see
+ [Nominatim/issues/1311](https://github.com/osm-search/Nominatim/issues/1311).
+- `nominatimlite::osm_amenities` data set deleted.
+
# nominatimlite 0.2.1
- Remove **osmdata** from Suggests.
diff --git a/R/bbox_to_poly.R b/R/bbox_to_poly.R
index 6132f1fa..96e50031 100644
--- a/R/bbox_to_poly.R
+++ b/R/bbox_to_poly.R
@@ -16,7 +16,6 @@
#' @seealso [sf::st_as_sfc()]
#'
#' @family spatial
-#' @family amenity
#'
#' @details
#'
diff --git a/R/data.R b/R/data.R
deleted file mode 100644
index e5891aa2..00000000
--- a/R/data.R
+++ /dev/null
@@ -1,43 +0,0 @@
-#' OpenStreetMap amenity database
-#'
-#' @description
-#' Database with the list of amenities available on OpenStreetMap.
-#'
-#' @family datasets
-#' @family amenity
-#'
-#' @encoding UTF-8
-#'
-#' @name osm_amenities
-#'
-#' @docType data
-#'
-#' @format A \CRANpkg{tibble} with with
-#' `r prettyNum(nrow(nominatimlite::osm_amenities), big.mark=",")` rows and
-#' fields:
-#' \describe{
-#' \item{category}{The category of the amenity}
-#' \item{amenity}{The name of the amenity}
-#' }
-#'
-#' @details
-#'
-#' ```{r, echo=FALSE}
-#'
-#' t <- nominatimlite::osm_amenities
-#'
-#' knitr::kable(t, col.names = c("**category**", "**amenity**"))
-#'
-#'
-#' ```
-#'
-#' @source
-#'
-#' @note Data extracted on **14 June 2021**.
-#'
-#' @examples
-#'
-#' amenities <- nominatimlite::osm_amenities
-#'
-#' amenities
-NULL
diff --git a/R/geo_amenity.R b/R/geo_amenity.R
index 29a31c9d..48a157bc 100644
--- a/R/geo_amenity.R
+++ b/R/geo_amenity.R
@@ -1,22 +1,18 @@
#' Geocode amenities
#'
#' @description
-#' This function search amenities as defined by OpenStreetMap on a restricted
-#' area defined by a bounding box in the form of
-#' `(, , , )`. This
-#' function returns the \CRANpkg{tibble} associated with the query, see
-#' [geo_amenity_sf()] for retrieving the data as a spatial object
-#' (\CRANpkg{sf} format).
+#' `r lifecycle::badge("deprecated")`
+#'
+#' This operation is not supported any more. Use
+#' [**osmdata**](https://github.com/ropensci/osmdata) instead.
#'
#'
#' @param bbox A numeric vector of latitude and longitude
#' `(, , , )` that
#' restrict the search area. See **Details**.
#' @param amenity A character of a vector of character with the amenities to be
-#' geolocated (i.e. `c("pub", "restaurant")`). See **Details** and
-#' [nominatimlite::osm_amenities].
+#' geolocated (i.e. `c("pub", "restaurant")`).
#' @param custom_query API-specific parameters to be used.
-#' See [nominatimlite::geo_lite()].
#' @param strict Logical `TRUE/FALSE`. Force the results to be included inside
#' the `bbox`. Note that Nominatim default behavior may return results located
#' outside the provided bounding box.
@@ -26,8 +22,6 @@
#' @return A \CRANpkg{tibble} with the results.
#'
#' @seealso [geo_amenity_sf()]
-#' @family amenity
-#' @family geocoding
#' @details
#'
#' Bounding boxes can be located using different online tools, as
@@ -37,22 +31,7 @@
#' .
#'
#'
-#' @examplesIf nominatim_check_access()
-#' \donttest{
-#' # Times Square, NY, USA
-#' bbox <- c(-73.9894467311, 40.75573629, -73.9830630737, 40.75789245)
-#'
-#' geo_amenity(bbox = bbox, amenity = "restaurant")
-#'
-#' # Several amenities
-#' geo_amenity(bbox = bbox, amenity = c("restaurant", "pub"))
-#'
-#' # Increase limit and use with strict
-#' geo_amenity(
-#' bbox = bbox, amenity = c("restaurant", "pub"), limit = 10,
-#' strict = TRUE
-#' )
-#' }
+#' @keywords internal
#'
#' @export
geo_amenity <- function(bbox,
@@ -65,129 +44,12 @@ geo_amenity <- function(bbox,
verbose = FALSE,
custom_query = list(),
strict = FALSE) {
- if (limit > 50) {
- message(paste(
- "Nominatim provides 50 results as a maximum. ",
- "Your query may be incomplete"
- ))
- limit <- min(50, limit)
- }
-
-
- # Dedupe for query
- amenity <- as.character(amenity)
- init_key <- dplyr::tibble(query = amenity)
- key <- unique(amenity)
-
- all_res <- lapply(key, function(x) {
- geo_amenity_single(
- bbox = bbox,
- amenity = x,
- lat,
- long,
- limit,
- full_results,
- return_addresses,
- verbose,
- custom_query
+ if (requireNamespace("lifecycle", quietly = TRUE)) {
+ lifecycle::deprecate_stop("0.3.0", "geo_amenity()",
+ details = paste(
+ "Operation not supported any",
+ "more by the Nominatim API."
+ )
)
- })
-
- all_res <- dplyr::bind_rows(all_res)
- all_res <- dplyr::left_join(init_key, all_res, by = "query")
-
- if (strict) {
- strict <- all_res[lat] >= bbox[2] &
- all_res[lat] <= bbox[4] &
- all_res[long] >= bbox[1] &
- all_res[long] <= bbox[3]
-
- strict <- as.logical(strict)
-
- all_res <- all_res[strict, ]
- }
-
-
-
- return(all_res)
-}
-
-
-
-#' @noRd
-#' @inheritParams geo_amenity
-geo_amenity_single <- function(bbox,
- amenity,
- lat = "lat",
- long = "lon",
- limit = 1,
- full_results = TRUE,
- return_addresses = TRUE,
- verbose = FALSE,
- custom_query = list()) {
- # Step 1: Download ----
- bbox_txt <- paste0(bbox, collapse = ",")
-
- api <- "https://nominatim.openstreetmap.org/search?"
-
- url <- paste0(
- api, "viewbox=", bbox_txt, "&q=[", amenity,
- "]&format=json&limit=", limit
- )
-
- if (full_results) url <- paste0(url, "&addressdetails=1")
- if (!"bounded" %in% names(custom_query)) url <- paste0(url, "&bounded=1")
-
- # Add options
- url <- add_custom_query(custom_query, url)
-
- # Download to temp file
- json <- tempfile(fileext = ".json")
- res <- api_call(url, json, isFALSE(verbose))
-
- # Step 2: Read and parse results ----
-
- # Keep a tbl with the query
- tbl_query <- dplyr::tibble(query = amenity)
-
- # If no response...
- if (isFALSE(res)) {
- message(url, " not reachable.")
- out <- empty_tbl(tbl_query, lat, long)
- return(invisible(out))
- }
-
- result <- dplyr::as_tibble(jsonlite::fromJSON(json, flatten = TRUE))
-
- # Rename lat and lon
- nmes <- names(result)
- nmes[nmes == "lat"] <- lat
- nmes[nmes == "lon"] <- long
-
- names(result) <- nmes
-
- # Empty query
- if (nrow(result) == 0) {
- message("No results for query ", amenity)
- out <- empty_tbl(tbl_query, lat, long)
- return(invisible(out))
}
-
- # Coords as double
- result[lat] <- as.double(result[[lat]])
- result[long] <- as.double(result[[long]])
-
- # Add query
- result_clean <- result
- result_clean$query <- amenity
-
- # Keep names
- result_out <- keep_names(result_clean, return_addresses, full_results,
- colstokeep = c("query", lat, long)
- )
-
- # As tibble
- result_out <- dplyr::as_tibble(result_out)
-
- result_out
}
diff --git a/R/geo_amenity_sf.R b/R/geo_amenity_sf.R
index b02070ed..80d2b0f1 100644
--- a/R/geo_amenity_sf.R
+++ b/R/geo_amenity_sf.R
@@ -1,11 +1,11 @@
#' Geocode amenities in Spatial format
#'
#' @description
-#' This function search amenities as defined by OpenStreetMap on a restricted
-#' area defined by a bounding box in the form of
-#' `(, , , )`. This
-#' function returns the \CRANpkg{sf} spatial object associated with the query,
-#' see [geo_amenity()] for retrieving the data in \CRANpkg{tibble} format.
+#' `r lifecycle::badge("deprecated")`
+#'
+#' This operation is not supported any more. Use
+#' [**osmdata**](https://github.com/ropensci/osmdata) instead.
+#'
#'
#' @inheritParams geo_lite_sf
#' @inheritParams geo_amenity
@@ -22,37 +22,8 @@
#'
#' @inheritSection geo_lite_sf About Geometry Types
#'
-#' @seealso [geo_amenity()]
-#' @family amenity
-#' @family geocoding
-#' @family spatial
-#'
-#' @examplesIf nominatim_check_access()
-#' \donttest{
-#' # Madrid, Spain
-#'
-#' library(ggplot2)
-#'
-#' bbox <- c(-3.888954, 40.311977, -3.517916, 40.643729)
-#'
-#' # Restaurants and pubs
-#'
-#' rest_pub <- geo_amenity_sf(bbox, c("restaurant", "pub"), limit = 50)
-#'
-#' if (any(!sf::st_is_empty(rest_pub))) {
-#' ggplot(rest_pub) +
-#' geom_sf()
-#' }
+#' @keywords internal
#'
-#' # Hospital as polygon
-#'
-#' hosp <- geo_amenity_sf(bbox, "hospital", points_only = FALSE)
-#'
-#' if (any(!sf::st_is_empty(hosp))) {
-#' ggplot(hosp) +
-#' geom_sf()
-#' }
-#' }
#' @export
geo_amenity_sf <- function(bbox,
amenity,
@@ -63,133 +34,12 @@ geo_amenity_sf <- function(bbox,
custom_query = list(),
points_only = TRUE,
strict = FALSE) {
- if (limit > 50) {
- message(paste(
- "Nominatim provides 50 results as a maximum. ",
- "Your query may be incomplete"
- ))
- limit <- min(50, limit)
- }
-
-
- # Dedupe for query
- amenity <- as.character(amenity)
- init_key <- dplyr::tibble(query = amenity)
- key <- unique(amenity)
-
- all_res <- lapply(key, function(x) {
- geo_amenity_sf_single(
- bbox = bbox,
- amenity = x,
- limit,
- full_results,
- return_addresses,
- verbose,
- custom_query,
- points_only
+ if (requireNamespace("lifecycle", quietly = TRUE)) {
+ lifecycle::deprecate_stop("0.3.0", "geo_amenity_sf()",
+ details = paste(
+ "Operation not supported any",
+ "more by the Nominatim API."
+ )
)
- })
-
- all_res <- dplyr::bind_rows(all_res)
-
- all_res <- sf_to_tbl(all_res)
-
- # Handle dupes in sf
- if (!identical(as.character(init_key$query), key)) {
- # Join with indexes
- template <- sf::st_drop_geometry(all_res)[, "query"]
- template$rindex <- seq_len(nrow(template))
- getrows <- dplyr::left_join(init_key, template, by = "query")
-
- # Select rows
- all_res <- all_res[as.integer(getrows$rindex), ]
- all_res <- sf_to_tbl(all_res)
- }
-
- if (strict) {
- bbox_sf <- bbox_to_poly(bbox)
- strict <- sf::st_covered_by(all_res, bbox_sf, sparse = FALSE)
- all_res <- all_res[strict, ]
- all_res <- sf_to_tbl(all_res)
- }
-
- return(all_res)
-}
-
-
-
-#' @noRd
-#' @inheritParams geo_amenity_sf
-geo_amenity_sf_single <- function(bbox,
- amenity,
- limit = 1,
- full_results = TRUE,
- return_addresses = TRUE,
- verbose = FALSE,
- custom_query = list(),
- points_only = TRUE) {
- # Step 1: Download ----
- bbox_txt <- paste0(bbox, collapse = ",")
- api <- "https://nominatim.openstreetmap.org/search?"
-
- url <- paste0(
- api, "viewbox=", bbox_txt, "&q=[", amenity,
- "]&format=geojson&limit=", limit
- )
-
-
- if (full_results) url <- paste0(url, "&addressdetails=1")
- if (!isTRUE(points_only)) url <- paste0(url, "&polygon_geojson=1")
- if (!"bounded" %in% names(custom_query)) url <- paste0(url, "&bounded=1")
-
- # Add options
- url <- add_custom_query(custom_query, url)
-
- # Download to temp file
- json <- tempfile(fileext = ".geojson")
- res <- api_call(url, json, quiet = isFALSE(verbose))
-
- # Step 2: Read and parse results ----
-
- # Keep a tbl with the query
- tbl_query <- dplyr::tibble(query = amenity)
-
- # If no response...
- if (isFALSE(res)) {
- message(url, " not reachable.")
- out <- empty_sf(tbl_query)
- return(invisible(out))
- }
-
- # Read
- sfobj <- sf::read_sf(json, stringsAsFactors = FALSE)
-
- # Empty query
- if (length(names(sfobj)) == 1) {
- message("No results for query ", amenity)
- out <- empty_sf(tbl_query)
- return(invisible(out))
}
-
-
- # Prepare output
-
- # Unnest address
- sfobj <- unnest_sf(sfobj)
-
-
-
- # Prepare output
- sf_clean <- sfobj
- sf_clean$query <- amenity
-
- # Keep names
- result_out <- keep_names(sf_clean, return_addresses, full_results,
- colstokeep = "query"
- )
-
- # Attach as tibble
- result_out <- sf_to_tbl(result_out)
-
- result_out
}
diff --git a/README.md b/README.md
index e88a7a0f..19d35c2a 100644
--- a/README.md
+++ b/README.md
@@ -212,7 +212,7 @@ A BibTeX entry for LaTeX users is
version = {0.2.1.9000},
doi = {10.5281/zenodo.5113195},
url = {https://dieghernan.github.io/nominatimlite/},
- abstract = {Lite interface for getting data from OSM service Nominatim . Extract coordinates from addresses, find places near a set of coordinates, search for amenities and return spatial objects on sf format.},
+ abstract = {Lite interface for getting data from OSM service Nominatim . Extract coordinates from addresses, find places near a set of coordinates and return spatial objects on sf format.},
}
## References
diff --git a/codemeta.json b/codemeta.json
index ac32e744..b5a9a8c9 100644
--- a/codemeta.json
+++ b/codemeta.json
@@ -2,7 +2,7 @@
"@context": "https://doi.org/10.5063/schema/codemeta-2.0",
"@type": "SoftwareSourceCode",
"identifier": "nominatimlite",
- "description": "Lite interface for getting data from 'OSM' service 'Nominatim' . Extract coordinates from addresses, find places near a set of coordinates, search for amenities and return spatial objects on 'sf' format.",
+ "description": "Lite interface for getting data from 'OSM' service 'Nominatim' . Extract coordinates from addresses, find places near a set of coordinates and return spatial objects on 'sf' format.",
"name": "nominatimlite: Interface with 'Nominatim' API Service",
"relatedLink": ["https://dieghernan.github.io/nominatimlite/", "https://CRAN.R-project.org/package=nominatimlite"],
"codeRepository": "https://github.com/dieghernan/nominatimlite",
@@ -154,6 +154,18 @@
"sameAs": "https://CRAN.R-project.org/package=jsonlite"
},
"4": {
+ "@type": "SoftwareApplication",
+ "identifier": "lifecycle",
+ "name": "lifecycle",
+ "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=lifecycle"
+ },
+ "5": {
"@type": "SoftwareApplication",
"identifier": "sf",
"name": "sf",
@@ -166,7 +178,7 @@
},
"sameAs": "https://CRAN.R-project.org/package=sf"
},
- "5": {
+ "6": {
"@type": "SoftwareApplication",
"identifier": "utils",
"name": "utils"
@@ -175,7 +187,7 @@
},
"applicationCategory": "cartography",
"keywords": ["r", "geocoding", "openstreetmap", "address", "nominatim", "reverse-geocoding", "rstats", "shapefile", "r-package", "spatial", "cran", "api-wrapper", "api", "gis"],
- "fileSize": "260.248KB",
+ "fileSize": "247.262KB",
"citation": [
{
"@type": "SoftwareSourceCode",
diff --git a/data/osm_amenities.rda b/data/osm_amenities.rda
deleted file mode 100644
index 00e98fec..00000000
Binary files a/data/osm_amenities.rda and /dev/null differ
diff --git a/inst/schemaorg.json b/inst/schemaorg.json
index 96567435..b9266ee9 100644
--- a/inst/schemaorg.json
+++ b/inst/schemaorg.json
@@ -20,7 +20,7 @@
"familyName": "Hernangómez",
"givenName": "Diego"
},
- "description": "Lite interface for getting data from 'OSM' service 'Nominatim' . Extract coordinates from addresses, find places near a set of coordinates, search for amenities and return spatial objects on 'sf' format.",
+ "description": "Lite interface for getting data from 'OSM' service 'Nominatim' . Extract coordinates from addresses, find places near a set of coordinates and return spatial objects on 'sf' format.",
"license": "https://spdx.org/licenses/MIT",
"name": "nominatimlite: Interface with 'Nominatim' API Service",
"programmingLanguage": {
diff --git a/man/bbox_to_poly.Rd b/man/bbox_to_poly.Rd
index 4a3f66f1..5644db51 100644
--- a/man/bbox_to_poly.Rd
+++ b/man/bbox_to_poly.Rd
@@ -64,14 +64,7 @@ if (any(!sf::st_is_empty(sfobj))) {
Get spatial (\code{sf}) objects:
\code{\link{geo_address_lookup_sf}()},
-\code{\link{geo_amenity_sf}()},
\code{\link{geo_lite_sf}()},
\code{\link{reverse_geo_lite_sf}()}
-
-Search amenities:
-\code{\link{geo_amenity_sf}()},
-\code{\link{geo_amenity}()},
-\code{\link{osm_amenities}}
}
-\concept{amenity}
\concept{spatial}
diff --git a/man/figures/lifecycle-archived.svg b/man/figures/lifecycle-archived.svg
new file mode 100644
index 00000000..745ab0c7
--- /dev/null
+++ b/man/figures/lifecycle-archived.svg
@@ -0,0 +1,21 @@
+
diff --git a/man/figures/lifecycle-defunct.svg b/man/figures/lifecycle-defunct.svg
new file mode 100644
index 00000000..d5c9559e
--- /dev/null
+++ b/man/figures/lifecycle-defunct.svg
@@ -0,0 +1,21 @@
+
diff --git a/man/figures/lifecycle-deprecated.svg b/man/figures/lifecycle-deprecated.svg
new file mode 100644
index 00000000..b61c57c3
--- /dev/null
+++ b/man/figures/lifecycle-deprecated.svg
@@ -0,0 +1,21 @@
+
diff --git a/man/figures/lifecycle-experimental.svg b/man/figures/lifecycle-experimental.svg
new file mode 100644
index 00000000..5d88fc2c
--- /dev/null
+++ b/man/figures/lifecycle-experimental.svg
@@ -0,0 +1,21 @@
+
diff --git a/man/figures/lifecycle-maturing.svg b/man/figures/lifecycle-maturing.svg
new file mode 100644
index 00000000..897370ec
--- /dev/null
+++ b/man/figures/lifecycle-maturing.svg
@@ -0,0 +1,21 @@
+
diff --git a/man/figures/lifecycle-questioning.svg b/man/figures/lifecycle-questioning.svg
new file mode 100644
index 00000000..7c1721d0
--- /dev/null
+++ b/man/figures/lifecycle-questioning.svg
@@ -0,0 +1,21 @@
+
diff --git a/man/figures/lifecycle-soft-deprecated.svg b/man/figures/lifecycle-soft-deprecated.svg
new file mode 100644
index 00000000..9c166ff3
--- /dev/null
+++ b/man/figures/lifecycle-soft-deprecated.svg
@@ -0,0 +1,21 @@
+
diff --git a/man/figures/lifecycle-stable.svg b/man/figures/lifecycle-stable.svg
new file mode 100644
index 00000000..9bf21e76
--- /dev/null
+++ b/man/figures/lifecycle-stable.svg
@@ -0,0 +1,29 @@
+
diff --git a/man/figures/lifecycle-superseded.svg b/man/figures/lifecycle-superseded.svg
new file mode 100644
index 00000000..db8d757f
--- /dev/null
+++ b/man/figures/lifecycle-superseded.svg
@@ -0,0 +1,21 @@
+
diff --git a/man/geo_address_lookup.Rd b/man/geo_address_lookup.Rd
index af7ead1d..f5c95974 100644
--- a/man/geo_address_lookup.Rd
+++ b/man/geo_address_lookup.Rd
@@ -71,8 +71,6 @@ Address Lookup API:
Geocoding strings:
\code{\link{geo_address_lookup_sf}()},
-\code{\link{geo_amenity_sf}()},
-\code{\link{geo_amenity}()},
\code{\link{geo_lite_sf}()},
\code{\link{geo_lite}()}
}
diff --git a/man/geo_address_lookup_sf.Rd b/man/geo_address_lookup_sf.Rd
index a5c4c129..51b14ce5 100644
--- a/man/geo_address_lookup_sf.Rd
+++ b/man/geo_address_lookup_sf.Rd
@@ -111,14 +111,11 @@ Address Lookup API:
Geocoding strings:
\code{\link{geo_address_lookup}()},
-\code{\link{geo_amenity_sf}()},
-\code{\link{geo_amenity}()},
\code{\link{geo_lite_sf}()},
\code{\link{geo_lite}()}
Get spatial (\code{sf}) objects:
\code{\link{bbox_to_poly}()},
-\code{\link{geo_amenity_sf}()},
\code{\link{geo_lite_sf}()},
\code{\link{reverse_geo_lite_sf}()}
}
diff --git a/man/geo_amenity.Rd b/man/geo_amenity.Rd
index 6846f20b..c0aeef23 100644
--- a/man/geo_amenity.Rd
+++ b/man/geo_amenity.Rd
@@ -23,8 +23,7 @@ geo_amenity(
restrict the search area. See \strong{Details}.}
\item{amenity}{A character of a vector of character with the amenities to be
-geolocated (i.e. \code{c("pub", "restaurant")}). See \strong{Details} and
-\link{osm_amenities}.}
+geolocated (i.e. \code{c("pub", "restaurant")}).}
\item{lat}{latitude column name in the output data (default \code{"lat"}).}
@@ -41,8 +40,7 @@ returned. See also \code{return_addresses}.}
\item{verbose}{if \code{TRUE} then detailed logs are output to the console.}
-\item{custom_query}{API-specific parameters to be used.
-See \code{\link[=geo_lite]{geo_lite()}}.}
+\item{custom_query}{API-specific parameters to be used.}
\item{strict}{Logical \code{TRUE/FALSE}. Force the results to be included inside
the \code{bbox}. Note that Nominatim default behavior may return results located
@@ -52,12 +50,10 @@ outside the provided bounding box.}
A \CRANpkg{tibble} with the results.
}
\description{
-This function search amenities as defined by OpenStreetMap on a restricted
-area defined by a bounding box in the form of
-\verb{(, , , )}. This
-function returns the \CRANpkg{tibble} associated with the query, see
-\code{\link[=geo_amenity_sf]{geo_amenity_sf()}} for retrieving the data as a spatial object
-(\CRANpkg{sf} format).
+\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
@@ -66,39 +62,7 @@ Bounding boxes can be located using different online tools, as
For a full list of valid amenities see
\url{https://wiki.openstreetmap.org/wiki/Key:amenity}.
}
-\examples{
-\dontshow{if (nominatim_check_access()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
-\donttest{
-# Times Square, NY, USA
-bbox <- c(-73.9894467311, 40.75573629, -73.9830630737, 40.75789245)
-
-geo_amenity(bbox = bbox, amenity = "restaurant")
-
-# Several amenities
-geo_amenity(bbox = bbox, amenity = c("restaurant", "pub"))
-
-# Increase limit and use with strict
-geo_amenity(
- bbox = bbox, amenity = c("restaurant", "pub"), limit = 10,
- strict = TRUE
-)
-}
-\dontshow{\}) # examplesIf}
-}
\seealso{
\code{\link[=geo_amenity_sf]{geo_amenity_sf()}}
-
-Search amenities:
-\code{\link{bbox_to_poly}()},
-\code{\link{geo_amenity_sf}()},
-\code{\link{osm_amenities}}
-
-Geocoding strings:
-\code{\link{geo_address_lookup_sf}()},
-\code{\link{geo_address_lookup}()},
-\code{\link{geo_amenity_sf}()},
-\code{\link{geo_lite_sf}()},
-\code{\link{geo_lite}()}
}
-\concept{amenity}
-\concept{geocoding}
+\keyword{internal}
diff --git a/man/geo_amenity_sf.Rd b/man/geo_amenity_sf.Rd
index e1a2fc45..f492c596 100644
--- a/man/geo_amenity_sf.Rd
+++ b/man/geo_amenity_sf.Rd
@@ -22,8 +22,7 @@ geo_amenity_sf(
restrict the search area. See \strong{Details}.}
\item{amenity}{A character of a vector of character with the amenities to be
-geolocated (i.e. \code{c("pub", "restaurant")}). See \strong{Details} and
-\link{osm_amenities}.}
+geolocated (i.e. \code{c("pub", "restaurant")}).}
\item{limit}{maximum number of results to return per input address. Note
that each query returns a maximum of 50 results.}
@@ -51,11 +50,10 @@ outside the provided bounding box.}
A \CRANpkg{sf} object with the results.
}
\description{
-This function search amenities as defined by OpenStreetMap on a restricted
-area defined by a bounding box in the form of
-\verb{(, , , )}. This
-function returns the \CRANpkg{sf} spatial object associated with the query,
-see \code{\link[=geo_amenity]{geo_amenity()}} for retrieving the data in \CRANpkg{tibble} format.
+\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
@@ -84,56 +82,4 @@ 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{
-\dontshow{if (nominatim_check_access()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
-\donttest{
-# Madrid, Spain
-
-library(ggplot2)
-
-bbox <- c(-3.888954, 40.311977, -3.517916, 40.643729)
-
-# Restaurants and pubs
-
-rest_pub <- geo_amenity_sf(bbox, c("restaurant", "pub"), limit = 50)
-
-if (any(!sf::st_is_empty(rest_pub))) {
- ggplot(rest_pub) +
- geom_sf()
-}
-
-# Hospital as polygon
-
-hosp <- geo_amenity_sf(bbox, "hospital", points_only = FALSE)
-
-if (any(!sf::st_is_empty(hosp))) {
- ggplot(hosp) +
- geom_sf()
-}
-}
-\dontshow{\}) # examplesIf}
-}
-\seealso{
-\code{\link[=geo_amenity]{geo_amenity()}}
-
-Search amenities:
-\code{\link{bbox_to_poly}()},
-\code{\link{geo_amenity}()},
-\code{\link{osm_amenities}}
-
-Geocoding strings:
-\code{\link{geo_address_lookup_sf}()},
-\code{\link{geo_address_lookup}()},
-\code{\link{geo_amenity}()},
-\code{\link{geo_lite_sf}()},
-\code{\link{geo_lite}()}
-
-Get spatial (\code{sf}) objects:
-\code{\link{bbox_to_poly}()},
-\code{\link{geo_address_lookup_sf}()},
-\code{\link{geo_lite_sf}()},
-\code{\link{reverse_geo_lite_sf}()}
-}
-\concept{amenity}
-\concept{geocoding}
-\concept{spatial}
+\keyword{internal}
diff --git a/man/geo_lite.Rd b/man/geo_lite.Rd
index e83853f5..1f76e33e 100644
--- a/man/geo_lite.Rd
+++ b/man/geo_lite.Rd
@@ -77,8 +77,6 @@ geo_lite(c("Madrid", "Barcelona"),
Geocoding strings:
\code{\link{geo_address_lookup_sf}()},
\code{\link{geo_address_lookup}()},
-\code{\link{geo_amenity_sf}()},
-\code{\link{geo_amenity}()},
\code{\link{geo_lite_sf}()}
}
\concept{geocoding}
diff --git a/man/geo_lite_sf.Rd b/man/geo_lite_sf.Rd
index 5239509d..72058fb9 100644
--- a/man/geo_lite_sf.Rd
+++ b/man/geo_lite_sf.Rd
@@ -113,14 +113,11 @@ if (any(!sf::st_is_empty(Madrid))) {
Geocoding strings:
\code{\link{geo_address_lookup_sf}()},
\code{\link{geo_address_lookup}()},
-\code{\link{geo_amenity_sf}()},
-\code{\link{geo_amenity}()},
\code{\link{geo_lite}()}
Get spatial (\code{sf}) objects:
\code{\link{bbox_to_poly}()},
\code{\link{geo_address_lookup_sf}()},
-\code{\link{geo_amenity_sf}()},
\code{\link{reverse_geo_lite_sf}()}
}
\concept{geocoding}
diff --git a/man/nominatimlite-package.Rd b/man/nominatimlite-package.Rd
index 1ba31c09..3a627e0d 100644
--- a/man/nominatimlite-package.Rd
+++ b/man/nominatimlite-package.Rd
@@ -8,7 +8,7 @@
\description{
\if{html}{\figure{logo.png}{options: style='float: right' alt='logo' width='120'}}
-Lite interface for getting data from 'OSM' service 'Nominatim' \url{https://nominatim.org/release-docs/latest/}. Extract coordinates from addresses, find places near a set of coordinates, search for amenities and return spatial objects on 'sf' format.
+Lite interface for getting data from 'OSM' service 'Nominatim' \url{https://nominatim.org/release-docs/latest/}. Extract coordinates from addresses, find places near a set of coordinates and return spatial objects on 'sf' format.
}
\seealso{
Useful links:
diff --git a/man/osm_amenities.Rd b/man/osm_amenities.Rd
deleted file mode 100644
index 6a7fed59..00000000
--- a/man/osm_amenities.Rd
+++ /dev/null
@@ -1,144 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/data.R
-\docType{data}
-\encoding{UTF-8}
-\name{osm_amenities}
-\alias{osm_amenities}
-\title{OpenStreetMap amenity database}
-\format{
-A \CRANpkg{tibble} with with
-100 rows and
-fields:
-\describe{
-\item{category}{The category of the amenity}
-\item{amenity}{The name of the amenity}
-}
-}
-\source{
-\url{https://wiki.openstreetmap.org/wiki/Key:amenity}
-}
-\description{
-Database with the list of amenities available on OpenStreetMap.
-}
-\details{
-\tabular{ll}{
- \strong{category} \tab \strong{amenity} \cr
- Sustenance \tab bar \cr
- Sustenance \tab biergarten \cr
- Sustenance \tab cafe \cr
- Sustenance \tab fast_food \cr
- Sustenance \tab food_court \cr
- Sustenance \tab ice_cream \cr
- Sustenance \tab pub \cr
- Sustenance \tab restaurant \cr
- Education \tab college \cr
- Education \tab driving_school \cr
- Education \tab kindergarten \cr
- Education \tab language_school \cr
- Education \tab library \cr
- Education \tab toy_library \cr
- Education \tab music_school \cr
- Education \tab school \cr
- Education \tab university \cr
- Transportation \tab bicycle_parking \cr
- Transportation \tab bicycle_repair_station \cr
- Transportation \tab bicycle_rental \cr
- Transportation \tab boat_rental \cr
- Transportation \tab boat_sharing \cr
- Transportation \tab bus_station \cr
- Transportation \tab car_rental \cr
- Transportation \tab car_sharing \cr
- Transportation \tab car_wash \cr
- Transportation \tab vehicle_inspection \cr
- Transportation \tab charging_station \cr
- Transportation \tab ferry_terminal \cr
- Transportation \tab fuel \cr
- Transportation \tab grit_bin \cr
- Transportation \tab motorcycle_parking \cr
- Transportation \tab parking \cr
- Transportation \tab parking_entrance \cr
- Transportation \tab parking_space \cr
- Transportation \tab taxi \cr
- Financial \tab atm \cr
- Financial \tab bank \cr
- Financial \tab bureau_de_change \cr
- Healthcare \tab baby_hatch \cr
- Healthcare \tab clinic \cr
- Healthcare \tab dentist \cr
- Healthcare \tab doctors \cr
- Healthcare \tab hospital \cr
- Healthcare \tab nursing_home \cr
- Healthcare \tab pharmacy \cr
- Healthcare \tab social_facility \cr
- Healthcare \tab veterinary \cr
- Entertainment-Arts-Culture \tab arts_centre \cr
- Entertainment-Arts-Culture \tab brothel \cr
- Entertainment-Arts-Culture \tab casino \cr
- Entertainment-Arts-Culture \tab cinema \cr
- Entertainment-Arts-Culture \tab community_centre \cr
- Entertainment-Arts-Culture \tab conference_centre \cr
- Entertainment-Arts-Culture \tab events_venue \cr
- Entertainment-Arts-Culture \tab fountain \cr
- Entertainment-Arts-Culture \tab gambling \cr
- Entertainment-Arts-Culture \tab love_hotel \cr
- Entertainment-Arts-Culture \tab nightclub \cr
- Entertainment-Arts-Culture \tab planetarium \cr
- Entertainment-Arts-Culture \tab public_bookcase \cr
- Entertainment-Arts-Culture \tab social_centre \cr
- Entertainment-Arts-Culture \tab stripclub \cr
- Entertainment-Arts-Culture \tab studio \cr
- Entertainment-Arts-Culture \tab swingerclub \cr
- Entertainment-Arts-Culture \tab theatre \cr
- Public Service \tab courthouse \cr
- Public Service \tab embassy \cr
- Public Service \tab fire_station \cr
- Public Service \tab police \cr
- Public Service \tab post_box \cr
- Public Service \tab post_depot \cr
- Public Service \tab post_office \cr
- Public Service \tab prison \cr
- Public Service \tab ranger_station \cr
- Public Service \tab townhall \cr
- Facilities \tab bbq \cr
- Facilities \tab bench \cr
- Facilities \tab dog_toilet \cr
- Facilities \tab drinking_water \cr
- Facilities \tab give_box \cr
- Facilities \tab shelter \cr
- Facilities \tab shower \cr
- Facilities \tab telephone \cr
- Facilities \tab toilets \cr
- Facilities \tab water_point \cr
- Facilities \tab watering_place \cr
- Waste Management \tab sanitary_dump_station \cr
- Waste Management \tab recycling \cr
- Waste Management \tab waste_basket \cr
- Waste Management \tab waste_disposal \cr
- Waste Management \tab waste_transfer_station \cr
- Others \tab animal_boarding \cr
- Others \tab animal_breeding \cr
- Others \tab animal_shelter \cr
- Others \tab baking_oven \cr
- Others \tab childcare \cr
- Others \tab clock \cr
- Others \tab crematorium \cr
- Others \tab dive_centre \cr
-}
-}
-\note{
-Data extracted on \strong{14 June 2021}.
-}
-\examples{
-
-amenities <- nominatimlite::osm_amenities
-
-amenities
-}
-\seealso{
-Search amenities:
-\code{\link{bbox_to_poly}()},
-\code{\link{geo_amenity_sf}()},
-\code{\link{geo_amenity}()}
-}
-\concept{amenity}
-\concept{datasets}
diff --git a/man/reverse_geo_lite_sf.Rd b/man/reverse_geo_lite_sf.Rd
index 572baa72..c53d1a6d 100644
--- a/man/reverse_geo_lite_sf.Rd
+++ b/man/reverse_geo_lite_sf.Rd
@@ -143,7 +143,6 @@ Reverse geocoding coordinates:
Get spatial (\code{sf}) objects:
\code{\link{bbox_to_poly}()},
\code{\link{geo_address_lookup_sf}()},
-\code{\link{geo_amenity_sf}()},
\code{\link{geo_lite_sf}()}
}
\concept{reverse}
diff --git a/man/roxygen/meta.R b/man/roxygen/meta.R
index 3f731d8c..ee4c8a6e 100644
--- a/man/roxygen/meta.R
+++ b/man/roxygen/meta.R
@@ -1,7 +1,6 @@
list(
rd_family_title = list(
lookup = "Address Lookup API: ",
- amenity = "Search amenities: ",
geocoding = "Geocoding strings: ",
reverse = "Reverse geocoding coordinates: ",
spatial = "Get spatial (\\code{sf}) objects: ",
diff --git a/pkgdown/_pkgdown.yml b/pkgdown/_pkgdown.yml
index a9d066c4..1c0810aa 100644
--- a/pkgdown/_pkgdown.yml
+++ b/pkgdown/_pkgdown.yml
@@ -40,11 +40,6 @@ reference:
contents:
- has_concept("spatial")
-- title: Datasets
- desc: Helper datasets.
- contents:
- - has_concept("datasets")
-
- title: About the package
contents:
- nominatimlite-package
diff --git a/tests/testthat/_snaps/geo_amenity.md b/tests/testthat/_snaps/geo_amenity.md
new file mode 100644
index 00000000..5264cbf6
--- /dev/null
+++ b/tests/testthat/_snaps/geo_amenity.md
@@ -0,0 +1,9 @@
+# Deprecated
+
+ Code
+ geo_amenity()
+ Condition
+ Error:
+ ! `geo_amenity()` was deprecated in nominatimlite 0.3.0 and is now defunct.
+ 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
new file mode 100644
index 00000000..5139302d
--- /dev/null
+++ b/tests/testthat/_snaps/geo_amenity_sf.md
@@ -0,0 +1,9 @@
+# Deprecated
+
+ Code
+ geo_amenity_sf()
+ Condition
+ Error:
+ ! `geo_amenity_sf()` was deprecated in nominatimlite 0.3.0 and is now defunct.
+ i Operation not supported any more by the Nominatim API.
+
diff --git a/tests/testthat/test-geo_amenity.R b/tests/testthat/test-geo_amenity.R
index 5648b43f..b8964b37 100644
--- a/tests/testthat/test-geo_amenity.R
+++ b/tests/testthat/test-geo_amenity.R
@@ -1,190 +1,5 @@
-test_that("Returning not reachable", {
- expect_message(geo_amenity(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- amenity = "xbzbzbzoa aiaia"
- ), "not reachable")
+test_that("Deprecated", {
+ skip_if_not_installed("lifecycle")
- skip_on_cran()
- skip_if_api_server()
-
- expect_message(obj <- geo_amenity(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- amenity = "xbzbzbzoa aiaia"
- ))
-
- expect_true(nrow(obj) == 1)
- expect_true(obj$query == "xbzbzbzoa aiaia")
- expect_s3_class(obj, "tbl")
- expect_identical(names(obj), c("query", "lat", "lon"))
- expect_true(all(
- vapply(obj, class, FUN.VALUE = character(1))
- == c("character", rep("numeric", 2))
- ))
- expect_true(is.na(obj$lat))
- expect_true(is.na(obj$lon))
-
- expect_message(
- obj_renamed <- geo_amenity(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- amenity = "xbzbzbzoa aiaia",
- lat = "lata",
- long = "longa"
- ),
- "not reachable"
- )
-
- expect_identical(names(obj_renamed), c("query", "lata", "longa"))
-
- names(obj_renamed) <- names(obj)
-
- expect_identical(obj, obj_renamed)
-})
-
-test_that("Returning empty query", {
- skip_on_cran()
- skip_if_api_server()
-
-
- expect_message(
- obj <- geo_amenity(
- bbox = c(-88.1446, 41.5022, -87.4854, 41.8795),
- amenity = "grit_bin"
- ),
- "No results"
- )
-
-
- expect_true(nrow(obj) == 1)
- expect_true(obj$query == "grit_bin")
- expect_s3_class(obj, "tbl")
- expect_identical(names(obj), c("query", "lat", "lon"))
- expect_true(all(
- vapply(obj, class, FUN.VALUE = character(1))
- == c("character", rep("numeric", 2))
- ))
- expect_true(is.na(obj$lat))
- expect_true(is.na(obj$lon))
-
- expect_message(
- obj_renamed <- geo_amenity(
- bbox = c(-88.1446, 41.5022, -87.4854, 41.8795),
- amenity = "grit_bin",
- lat = "lata",
- long = "longa"
- ),
- "No results"
- )
-
- expect_identical(names(obj_renamed), c("query", "lata", "longa"))
-
- names(obj_renamed) <- names(obj)
-
- expect_identical(obj, obj_renamed)
-})
-
-
-test_that("Data format", {
- skip_on_cran()
- skip_if_api_server()
- skip_if_offline()
-
- obj <- geo_amenity(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- c("pub", "restaurant"),
- )
-
- expect_s3_class(obj, "tbl")
- expect_false(inherits(obj, "sf"))
-})
-
-test_that("Checking query", {
- skip_on_cran()
- skip_if_api_server()
- skip_if_offline()
-
- expect_message(obj <- geo_amenity(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- c("pub", "restaurant"),
- limit = 51
- ), "50 results")
-
-
- expect_identical(names(obj), c("query", "lat", "lon", "address"))
-
- obj <- geo_amenity(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- "pub",
- long = "ong", lat = "at",
- full_results = FALSE,
- return_addresses = FALSE
- )
- expect_identical(names(obj), c("query", "at", "ong"))
-
- obj <- geo_amenity(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- "pub",
- long = "ong", lat = "at",
- full_results = FALSE,
- return_addresses = TRUE
- )
-
- expect_identical(names(obj), c("query", "at", "ong", "address"))
-
- obj <- geo_amenity(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- "pub",
- long = "ong", lat = "at",
- full_results = TRUE,
- return_addresses = FALSE
- )
-
- expect_identical(names(obj)[1:4], c("query", "at", "ong", "address"))
- expect_gt(ncol(obj), 4)
-
-
- expect_gt(nrow(geo_amenity(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- "pub",
- limit = 10,
- custom_query = list(countrycode = "es")
- )), 4)
- expect_equal(nrow(geo_amenity(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- "pub",
- custom_query = list(countrycode = "es")
- )), 1)
- expect_equal(nrow(geo_amenity(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- "pub",
- custom_query = list(extratags = 1)
- )), 1)
-
- expect_lt(nrow(geo_amenity(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- "pub",
- limit = 1,
- strict = TRUE
- )), 2)
-})
-
-test_that("Dedupe", {
- skip_on_cran()
- skip_if_api_server()
- skip_if_offline()
-
- # Dupes
- dup <- geo_amenity(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- rep(c("pub", "restaurant"), 50),
- limit = 1
- )
-
- expect_equal(nrow(dup), 100)
- expect_equal(as.character(dup$query), rep(c("pub", "restaurant"), 50))
-
- # Check deduping
- dedup <- dplyr::distinct(dup)
-
- expect_equal(nrow(dedup), 2)
- expect_equal(as.character(dedup$query), rep(c("pub", "restaurant"), 1))
+ expect_snapshot(geo_amenity(), error = TRUE)
})
diff --git a/tests/testthat/test-geo_amenity_sf.R b/tests/testthat/test-geo_amenity_sf.R
index bf87617a..02f8cbf6 100644
--- a/tests/testthat/test-geo_amenity_sf.R
+++ b/tests/testthat/test-geo_amenity_sf.R
@@ -1,209 +1,5 @@
-test_that("Returning not reachable", {
- expect_message(geo_amenity_sf(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- amenity = "xbzbzbzoa aiaia"
- ), "not reachable")
+test_that("Deprecated", {
+ skip_if_not_installed("lifecycle")
- skip_on_cran()
- skip_if_api_server()
-
- expect_message(
- obj <- geo_amenity_sf(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- amenity = "xbzbzbzoa aiaia"
- )
- )
-
- expect_true(nrow(obj) == 1)
- expect_true(obj$query == "xbzbzbzoa aiaia")
- expect_s3_class(obj, "sf")
- expect_s3_class(obj, "tbl")
- expect_true(sf::st_is_empty(obj))
- expect_identical(sf::st_crs(obj), sf::st_crs(4326))
-})
-
-
-test_that("Returning empty query", {
- skip_on_cran()
- skip_if_api_server()
-
-
- expect_message(
- obj <- geo_amenity_sf(
- bbox = c(-88.1446, 41.5022, -87.4854, 41.8795),
- amenity = "grit_bin"
- ),
- "No results"
- )
-
-
- expect_true(nrow(obj) == 1)
- expect_true(obj$query == "grit_bin")
- expect_s3_class(obj, "sf")
- expect_s3_class(obj, "tbl")
- expect_true(sf::st_is_empty(obj))
- expect_identical(sf::st_crs(obj), sf::st_crs(4326))
-})
-
-
-test_that("Data format", {
- skip_on_cran()
- skip_if_api_server()
- skip_if_offline()
-
- obj <- geo_amenity_sf(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- c("pub", "restaurant"),
- )
-
- expect_s3_class(obj, "sf")
- expect_s3_class(obj, "tbl")
- expect_equal(nrow(obj), 2)
- expect_identical(as.character(obj$query), c("pub", "restaurant"))
-
-
- # Polygon
-
- expect_message(
- hosp <- geo_amenity_sf(
- c(
- -3.888954, 40.311977,
- -3.517916, 40.643729
- ),
- c("hospital", "dump", "pub"),
- points_only = FALSE
- ), "No results for query dump"
- )
-
- expect_s3_class(hosp, "sf")
- expect_s3_class(hosp, "tbl")
- expect_equal(nrow(hosp), 3)
- expect_identical(as.character(hosp$query), c("hospital", "dump", "pub"))
- expect_identical(sf::st_is_empty(hosp), c(FALSE, TRUE, FALSE))
-})
-
-
-test_that("Checking query", {
- skip_on_cran()
- skip_if_api_server()
- skip_if_offline()
-
-
- expect_message(obj <- geo_amenity_sf(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- c("pub", "restaurant"),
- limit = 51
- ), "50 results")
-
-
- expect_identical(names(obj), c("query", "address", "geometry"))
- expect_s3_class(obj, "sf")
- expect_s3_class(obj, "tbl")
-
- obj <- geo_amenity_sf(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- "pub",
- full_results = FALSE,
- return_addresses = FALSE
- )
- expect_identical(names(obj), c("query", "geometry"))
- expect_s3_class(obj, "sf")
- expect_s3_class(obj, "tbl")
-
- obj <- geo_amenity_sf(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- "pub",
- full_results = FALSE,
- return_addresses = TRUE
- )
-
- expect_identical(names(obj), c("query", "address", "geometry"))
- expect_s3_class(obj, "sf")
- expect_s3_class(obj, "tbl")
-
- obj <- geo_amenity_sf(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- "pub",
- full_results = TRUE,
- return_addresses = FALSE
- )
-
- expect_identical(names(obj)[1:2], c("query", "address"))
- expect_gt(ncol(obj), 3)
- expect_s3_class(obj, "sf")
- expect_s3_class(obj, "tbl")
- expect_identical(attributes(obj)$sf_column, "geometry")
-
- expect_gt(nrow(geo_amenity_sf(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- "pub",
- limit = 10,
- custom_query = list(countrycode = "es")
- )), 4)
-
-
- expect_equal(nrow(geo_amenity_sf(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- "pub",
- custom_query = list(countrycode = "es")
- )), 1)
-
- expect_equal(nrow(geo_amenity_sf(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- "pub",
- custom_query = list(extratags = 1)
- )), 1)
-
- expect_lt(nrow(geo_amenity_sf(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- "pub",
- limit = 1,
- strict = TRUE
- )), 2)
-})
-
-
-test_that("Dedupe", {
- skip_on_cran()
- skip_if_api_server()
- skip_if_offline()
-
- # Dupes
- dup <- geo_amenity_sf(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- rep(c("pub", "restaurant"), 50),
- limit = 1
- )
-
- expect_s3_class(dup, "sf")
- expect_s3_class(dup, "tbl")
-
- expect_equal(nrow(dup), 100)
- expect_equal(as.character(dup$query), rep(c("pub", "restaurant"), 50))
-
- # Check deduping
- dedup <- dplyr::distinct(dup)
-
- expect_equal(nrow(dedup), 2)
- expect_equal(as.character(dedup$query), rep(c("pub", "restaurant"), 1))
-})
-
-
-test_that("Verify names", {
- skip_on_cran()
- skip_if_api_server()
- skip_if_offline()
-
- # Ok
- several <- geo_amenity_sf(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- c("pub", "restaurant"),
- limit = 20,
- full_results = TRUE
- )
-
- expect_identical(names(several), unique(names(several)))
-
- # Do I have dups by any chance?
- expect_false(any(grepl("\\.[0-9]$", names(several))))
+ expect_snapshot(geo_amenity_sf(), error = TRUE)
})
diff --git a/vignettes/nominatimlite.Rmd b/vignettes/nominatimlite.Rmd
index 9c62de83..943a67b0 100644
--- a/vignettes/nominatimlite.Rmd
+++ b/vignettes/nominatimlite.Rmd
@@ -13,6 +13,8 @@ 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
@@ -49,7 +51,8 @@ that presents similar features:
With `nominatimlite` you can extract spatial objects easily:
-``` r
+
+```r
library(nominatimlite)
# Extract some points - Pizza Hut in California
@@ -73,7 +76,8 @@ ggplot(CA) +
You can also extract polygon and line objects (if available) using the option
`points_only = FALSE`:
-``` r
+
+```r
sol_poly <- geo_lite_sf("Statue of Liberty, NY, USA", points_only = FALSE)
ggplot(sol_poly) +
@@ -90,7 +94,8 @@ Liberty](../man/figures/README-statue_liberty-1.png){width="100%"}
In this first example we will geocode a few addresses using the `geo_lite()`
function:
-``` r
+
+```r
library(tibble)
# create a dataframe with addresses
@@ -103,26 +108,22 @@ some_addresses <- tribble(
# geocode the addresses
lat_longs <- geo_lite(some_addresses$addr, lat = "latitude", long = "longitude")
-#>
- |
- | | 0%
- |
- |================= | 33% (1/3)
- |
- |================================= | 67% (2/3)
- |
- |==================================================| 100% (3/3)
+#>
|
| | 0%
|
|================= | 33% (1/3)
|
|================================= | 67% (2/3)
|
|==================================================| 100% (3/3)
```
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 |
+
+
+|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
@@ -130,27 +131,24 @@ we can use the `reverse_geo_lite()` function. The arguments are similar to the
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
+
+```r
reverse <- reverse_geo_lite(
lat = lat_longs$latitude, long = lat_longs$longitude,
address = "address_found"
)
-#>
- |
- | | 0%
- |
- |================= | 33% (1/3)
- |
- |================================= | 67% (2/3)
- |
- |==================================================| 100% (3/3)
+#>
|
| | 0%
|
|================= | 33% (1/3)
|
|================================= | 67% (2/3)
|
|==================================================| 100% (3/3)
```
-| 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 |
+
+
+|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