···11Package: osmdata
22Title: Import 'OpenStreetMap' Data as Simple Features or Spatial Objects
33-Version: 0.2.5.056
33+Version: 0.2.5.058
44Authors@R: c(
55 person("Mark", "Padgham", , "mark.padgham@email.com", role = c("aut", "cre")),
66 person("Bob", "Rudis", role = "aut"),
+1
NEWS.md
···88- Remove `magrittr` from imports. User code relaying on reexported pipe `%>%` from `osmdata` must exlicitly load it
99 with `library(magrittr)`. Code examples, tests and vignettes now use the pipe from base (`|>`) available since R 4.1
1010 (#361)
1111+- Deprecate `nodes_only` argument in `opq()`. Superseeded by argument `osm_types` (#362)
11121213## Minor changes
1314
+36-38
R/opq.R
···1212#' or \link{bbox_to_string} with a `data.frame` from `getbb(..., format_out
1313#' = "data.frame")` to select all areas combined (relations and ways).
1414#' @param nodes_only WARNING: this parameter is equivalent to
1515-#' `osm_types = "node"` and will be DEPRECATED. If `TRUE`, query OSM nodes
1616-#' only. Some OSM structures such as `place = "city"` or
1515+#' `osm_types = "node"` and is DEPRECATED. If `TRUE`, query OSM nodes
1616+#' only.
1717+#' @param osm_types A character vector with several OSM types to query: `node`,
1818+#' `way` and `relation` is the default. `nwr`, `nw`, `wr`, `nr` and `rel`
1919+#' are also valid types. Some OSM structures such as `place = "city"` or
1720#' `highway = "traffic_signals"` are represented by nodes only. Queries are
1821#' built by default to return all nodes, ways, and relation, but this can
1919-#' be very inefficient for node-only queries. Setting this value to `TRUE`
2020-#' for such cases makes queries more efficient, with data returned in the
2121-#' `osm_points` list item.
2222-#' @param osm_types A character vector with several OSM types to query: `node`,
2323-#' `way` and `relation` is the default. `nwr`, `nw`, `wr`, `nr` and `rel`
2424-#' are also valid types. Ignored if `nodes_only = TRUE`.
2525-#' `osm_types = "node"` is equivalent to `nodes_only = TRUE`.
2222+#' be very inefficient for node-only queries. Setting this value to `"node"`
2323+#' for such cases makes queries more efficient and, in [`osmdata_sf()`], the
2424+#' data will be returned in the `osm_points` list item only.
2625#' @param out The level of verbosity of the overpass result: `body` (geometries
2726#' and tags, the default), `tags` (tags without geometry), `meta` (like
2827#' body + Timestamp, Version, Changeset, User, User ID of the last
···8281#' add_osm_feature ("amenity", "pub")
8382#' c (osmdata_sf (q1), osmdata_sf (q2)) # all restaurants OR pubs
8483#'
8585-#' # Use nodes_only to retrieve single point data only, such as for central
8484+#' # Use `osm_types = "node"` to retrieve single point data only, such as for central
8685#' # locations of cities.
8787-#' opq <- opq (bbox, nodes_only = TRUE) |>
8686+#' opq <- opq (bbox, osm_types = "node") |>
8887#' add_osm_feature (key = "place", value = "city") |>
8988#' osmdata_sf (quiet = FALSE)
9089#'
9190#' # Filter by a search area
9291#' qa1 <- getbb ("Catalan Countries", format_out = "osm_type_id") |>
9393-#' opq (nodes_only = TRUE) |>
9292+#' opq (osm_types = "node") |>
9493#' add_osm_feature (key = "capital", value = "4")
9594#' opqa1 <- osmdata_sf (qa1)
9695#' # Filter by a multiple search areas
9796#' bb <- getbb ("Vilafranca", format_out = "data.frame")
9897#' qa2 <- bbox_to_string (bb [bb$osm_type != "node", ]) |>
9999-#' opq (nodes_only = TRUE) |>
9898+#' opq (osm_types = "node") |>
10099#' add_osm_feature (key = "place")
101100#' opqa2 <- osmdata_sf (qa2)
102101#' }
103103-opq <- function (bbox = NULL, nodes_only = FALSE,
102102+opq <- function (bbox = NULL, nodes_only = NULL,
104103 osm_types = c ("node", "way", "relation"),
105104 out = c ("body", "tags", "meta", "skel", "tags center", "ids"),
106105 datetime = NULL, datetime2 = NULL, adiff = FALSE,
···109108 timeout <- format (timeout, scientific = FALSE)
110109 prefix <- paste0 ("[out:xml][timeout:", timeout, "]")
111110112112- if (nodes_only) {
113113- osm_types <- "node"
114114- } else {
115115- osm_types <- try (
116116- match.arg (osm_types,
117117- choices = c (
118118- "node", "way", "rel", "relation",
119119- "nwr", "nw", "wr", "nr"
120120- ),
121121- several.ok = TRUE
122122- ), silent = TRUE)
123123- if (inherits (osm_types, "try-error")) {
124124- stop ('osm_types parameter must be a vector with values from ',
125125- '"node", "way", "rel", "relation", ',
126126- '"nwr", "nw", "wr" and "nr".',
127127- call. = FALSE
128128- )
111111+ if (!is.null(nodes_only)) {
112112+ .Deprecated(msg = paste("The 'nodes_only' argument is deprecated",
113113+ "and will be removed in a future version.",
114114+ "Use 'osm_types = \"node\"' instead."))
115115+ if (nodes_only) {
116116+ osm_types <- "node"
129117 }
130118 }
131119120120+ osm_types <- try (
121121+ match.arg (osm_types,
122122+ choices = c (
123123+ "node", "way", "rel", "relation",
124124+ "nwr", "nw", "wr", "nr"
125125+ ),
126126+ several.ok = TRUE
127127+ ), silent = TRUE)
128128+ if (inherits (osm_types, "try-error")) {
129129+ stop ('osm_types parameter must be a vector with values from ',
130130+ '"node", "way", "rel", "relation", ',
131131+ '"nwr", "nw", "wr" and "nr".',
132132+ call. = FALSE
133133+ )
134134+ }
135135+132136 out <- try (match.arg (out), silent = TRUE)
133137 if (inherits (out, "try-error")) {
134138 stop ("out parameter must be ",
···137141 )
138142 }
139143140140- has_geometry <- !nodes_only && out %in% c ("body", "meta", "skel")
144144+ has_geometry <- !all (osm_types == "node") && out %in% c ("body", "meta", "skel")
141145 if (has_geometry) {
142146 suffix <- paste0 (");\n(._;>;);\nout ", out, ";") # recurse down
143147 } else {
···193197 class (res) <- c (class (res), "overpass_query")
194198 attr (res, "datetime") <- datetime
195199 attr (res, "datetime2") <- datetime2
196196- attr (res, "nodes_only") <- nodes_only
197200198201 return (res)
199202}
···756759 )
757760 class (res) <- c (class (res), "overpass_query")
758761 attr (res, "datetime") <- attr (res, "datetime2") <- NULL
759759- attr (res, "nodes_only") <- FALSE
760762 attr (res, "enclosing") <- enclosing
761763762764 return (res)
···914916opq_string_intern <- function (opq, quiet = TRUE) {
915917916918 lat <- lon <- NULL # suppress no visible binding messages
917917-918918- if (attr (opq, "nodes_only")) {
919919- opq$osm_types <- "node"
920920- }
921919922920 map_to_area <- grepl ("(node|way|relation|rel)\\(id:[0-9, ]+\\)", opq$bbox)
923921
+13-14
man/opq.Rd
···66\usage{
77opq(
88 bbox = NULL,
99- nodes_only = FALSE,
99+ nodes_only = NULL,
1010 osm_types = c("node", "way", "relation"),
1111 out = c("body", "tags", "meta", "skel", "tags center", "ids"),
1212 datetime = NULL,
···2828or \link{bbox_to_string} with a \code{data.frame} from \code{getbb(..., format_out = "data.frame")} to select all areas combined (relations and ways).}
29293030\item{nodes_only}{WARNING: this parameter is equivalent to
3131-\code{osm_types = "node"} and will be DEPRECATED. If \code{TRUE}, query OSM nodes
3232-only. Some OSM structures such as \code{place = "city"} or
3333-\code{highway = "traffic_signals"} are represented by nodes only. Queries are
3434-built by default to return all nodes, ways, and relation, but this can
3535-be very inefficient for node-only queries. Setting this value to \code{TRUE}
3636-for such cases makes queries more efficient, with data returned in the
3737-\code{osm_points} list item.}
3131+\code{osm_types = "node"} and is DEPRECATED. If \code{TRUE}, query OSM nodes
3232+only.}
38333934\item{osm_types}{A character vector with several OSM types to query: \code{node},
4035\code{way} and \code{relation} is the default. \code{nwr}, \code{nw}, \code{wr}, \code{nr} and \code{rel}
4141-are also valid types. Ignored if \code{nodes_only = TRUE}.
4242-\code{osm_types = "node"} is equivalent to \code{nodes_only = TRUE}.}
3636+are also valid types. Some OSM structures such as \code{place = "city"} or
3737+\code{highway = "traffic_signals"} are represented by nodes only. Queries are
3838+built by default to return all nodes, ways, and relation, but this can
3939+be very inefficient for node-only queries. Setting this value to \code{"node"}
4040+for such cases makes queries more efficient and, in \code{\link[=osmdata_sf]{osmdata_sf()}}, the
4141+data will be returned in the \code{osm_points} list item only.}
43424443\item{out}{The level of verbosity of the overpass result: \code{body} (geometries
4544and tags, the default), \code{tags} (tags without geometry), \code{meta} (like
···105104 add_osm_feature ("amenity", "pub")
106105c (osmdata_sf (q1), osmdata_sf (q2)) # all restaurants OR pubs
107106108108-# Use nodes_only to retrieve single point data only, such as for central
107107+# Use `osm_types = "node"` to retrieve single point data only, such as for central
109108# locations of cities.
110110-opq <- opq (bbox, nodes_only = TRUE) |>
109109+opq <- opq (bbox, osm_types = "node") |>
111110 add_osm_feature (key = "place", value = "city") |>
112111 osmdata_sf (quiet = FALSE)
113112114113# Filter by a search area
115114qa1 <- getbb ("Catalan Countries", format_out = "osm_type_id") |>
116116- opq (nodes_only = TRUE) |>
115115+ opq (osm_types = "node") |>
117116 add_osm_feature (key = "capital", value = "4")
118117opqa1 <- osmdata_sf (qa1)
119118# Filter by a multiple search areas
120119bb <- getbb ("Vilafranca", format_out = "data.frame")
121120qa2 <- bbox_to_string (bb [bb$osm_type != "node", ]) |>
122122- opq (nodes_only = TRUE) |>
121121+ opq (osm_types = "node") |>
123122 add_osm_feature (key = "place")
124123opqa2 <- osmdata_sf (qa2)
125124}
···278278 features = c ("[\"natural\"=\"water\"]", "[\"name:en\"=\"Dian\"]")
279279)
280280attr (q, "class") <- c ("list", "overpass_query")
281281-attr (q, "nodes_only") <- FALSE
282281```
283282284283Note that the `"="` symbols here requests features whose values exactly match