···1313#'
1414#' @examples
1515#' \dontrun{
1616-#' hampi_sf <- opq ("hampi india") %>%
1717-#' add_osm_feature (key = "historic", value = "ruins") %>%
1616+#' hampi_sf <- opq ("hampi india") |>
1717+#' add_osm_feature (key = "historic", value = "ruins") |>
1818#' osmdata_sc ()
1919#'
2020#' # Complex query as a string (not possible with regular osmdata functions)
+2-2
R/get-osmdata-sf.R
···1212#'
1313#' @examples
1414#' \dontrun{
1515-#' hampi_sf <- opq ("hampi india") %>%
1616-#' add_osm_feature (key = "historic", value = "ruins") %>%
1515+#' hampi_sf <- opq ("hampi india") |>
1616+#' add_osm_feature (key = "historic", value = "ruins") |>
1717#' osmdata_sf ()
1818#'
1919#' # Complex query as a string (not possible with regular osmdata functions)
+2-2
R/get-osmdata-sp.R
···2020#'
2121#' @examples
2222#' \dontrun{
2323-#' hampi_sp <- opq ("hampi india") %>%
2424-#' add_osm_feature (key = "historic", value = "ruins") %>%
2323+#' hampi_sp <- opq ("hampi india") |>
2424+#' add_osm_feature (key = "historic", value = "ruins") |>
2525#' osmdata_sp ()
2626#'
2727#' # Complex query as a string (not possible with regular osmdata functions)
+39-39
R/opq.R
···6969#'
7070#' @examples
7171#' \dontrun{
7272-#' q <- getbb ("portsmouth", display_name_contains = "United States") %>%
7373-#' opq () %>%
7474-#' add_osm_feature ("amenity", "restaurant") %>%
7272+#' q <- getbb ("portsmouth", display_name_contains = "United States") |>
7373+#' opq () |>
7474+#' add_osm_feature ("amenity", "restaurant") |>
7575#' add_osm_feature ("amenity", "pub")
7676#' osmdata_sf (q) # all objects that are restaurants AND pubs (there are none!)
7777-#' q1 <- getbb ("portsmouth", display_name_contains = "United States") %>%
7878-#' opq () %>%
7777+#' q1 <- getbb ("portsmouth", display_name_contains = "United States") |>
7878+#' opq () |>
7979#' add_osm_feature ("amenity", "restaurant")
8080-#' q2 <- getbb ("portsmouth", display_name_contains = "United States") %>%
8181-#' opq () %>%
8080+#' q2 <- getbb ("portsmouth", display_name_contains = "United States") |>
8181+#' opq () |>
8282#' add_osm_feature ("amenity", "pub")
8383#' c (osmdata_sf (q1), osmdata_sf (q2)) # all restaurants OR pubs
8484#'
8585#' # Use nodes_only to retrieve single point data only, such as for central
8686#' # locations of cities.
8787-#' opq <- opq (bbox, nodes_only = TRUE) %>%
8888-#' add_osm_feature (key = "place", value = "city") %>%
8787+#' opq <- opq (bbox, nodes_only = TRUE) |>
8888+#' add_osm_feature (key = "place", value = "city") |>
8989#' osmdata_sf (quiet = FALSE)
9090#'
9191#' # Filter by a search area
9292-#' qa1 <- getbb ("Catalan Countries", format_out = "osm_type_id") %>%
9393-#' opq (nodes_only = TRUE) %>%
9292+#' qa1 <- getbb ("Catalan Countries", format_out = "osm_type_id") |>
9393+#' opq (nodes_only = TRUE) |>
9494#' add_osm_feature (key = "capital", value = "4")
9595#' opqa1 <- osmdata_sf (qa1)
9696#' # Filter by a multiple search areas
9797#' bb <- getbb ("Vilafranca", format_out = "data.frame")
9898-#' qa2 <- bbox_to_string (bb [bb$osm_type != "node", ]) %>%
9999-#' opq (nodes_only = TRUE) %>%
9898+#' qa2 <- bbox_to_string (bb [bb$osm_type != "node", ]) |>
9999+#' opq (nodes_only = TRUE) |>
100100#' add_osm_feature (key = "place")
101101#' opqa2 <- osmdata_sf (qa2)
102102#' }
···285285#'
286286#' @examples
287287#' \dontrun{
288288-#' q <- opq ("portsmouth usa") %>%
288288+#' q <- opq ("portsmouth usa") |>
289289#' add_osm_feature (
290290#' key = "amenity",
291291#' value = "restaurant"
292292-#' ) %>%
292292+#' ) |>
293293#' add_osm_feature (key = "amenity", value = "pub")
294294#' osmdata_sf (q) # all objects that are restaurants AND pubs (there are none!)
295295-#' q1 <- opq ("portsmouth usa") %>%
295295+#' q1 <- opq ("portsmouth usa") |>
296296#' add_osm_feature (
297297#' key = "amenity",
298298#' value = "restaurant"
299299#' )
300300-#' q2 <- opq ("portsmouth usa") %>%
300300+#' q2 <- opq ("portsmouth usa") |>
301301#' add_osm_feature (key = "amenity", value = "pub")
302302#' c (osmdata_sf (q1), osmdata_sf (q2)) # all restaurants OR pubs
303303#' # Use of negation to extract all non-primary highways
304304-#' q <- opq ("portsmouth uk") %>%
304304+#' q <- opq ("portsmouth uk") |>
305305#' add_osm_feature (key = "highway", value = "!primary")
306306#'
307307#' # key negation without warnings
308308-#' q3 <- opq ("Vinçà", osm_type="node") %>%
308308+#' q3 <- opq ("Vinçà", osm_type="node") |>
309309#' add_osm_feature (key = c("name", "!name:ca"))
310310-#' q4 <- opq ("el Carxe", osm_type="node") %>%
311311-#' add_osm_feature (key = "natural", value = "peak") %>%
310310+#' q4 <- opq ("el Carxe", osm_type="node") |>
311311+#' add_osm_feature (key = "natural", value = "peak") |>
312312#' add_osm_feature (key = "!ele")
313313#' }
314314add_osm_feature <- function (opq,
···485485#'
486486#' @examples
487487#' \dontrun{
488488-#' q <- opq ("portsmouth usa") %>%
488488+#' q <- opq ("portsmouth usa") |>
489489#' add_osm_features (features = list (
490490#' "amenity" = "restaurant",
491491#' "amenity" = "pub"
492492#' ))
493493#'
494494-#' q <- opq ("portsmouth usa") %>%
494494+#' q <- opq ("portsmouth usa") |>
495495#' add_osm_features (features = c (
496496#' "\"amenity\"=\"restaurant\"",
497497#' "\"amenity\"=\"pub\""
498498#' ))
499499#' # This extracts in a single query the same result as the following:
500500-#' q1 <- opq ("portsmouth usa") %>%
500500+#' q1 <- opq ("portsmouth usa") |>
501501#' add_osm_feature (
502502#' key = "amenity",
503503#' value = "restaurant"
504504#' )
505505-#' q2 <- opq ("portsmouth usa") %>%
505505+#' q2 <- opq ("portsmouth usa") |>
506506#' add_osm_feature (key = "amenity", value = "pub")
507507#' c (osmdata_sf (q1), osmdata_sf (q2)) # all restaurants OR pubs
508508#' }
···620620#' @examples
621621#' \dontrun{
622622#' id <- c (1489221200, 1489221321, 1489221491)
623623-#' dat1 <- opq_osm_id (type = "node", id = id) %>%
624624-#' opq_string () %>%
623623+#' dat1 <- opq_osm_id (type = "node", id = id) |>
624624+#' opq_string () |>
625625#' osmdata_sf ()
626626#' dat1$osm_points # the desired nodes
627627#' id <- c (136190595, 136190596)
628628-#' dat2 <- opq_osm_id (type = "way", id = id) %>%
629629-#' opq_string () %>%
628628+#' dat2 <- opq_osm_id (type = "way", id = id) |>
629629+#' opq_string () |>
630630#' osmdata_sf ()
631631#' dat2$osm_lines # the desired ways
632632#' dat <- c (dat1, dat2) # The node and way data combined
633633#' # All in one (same result as dat)
634634#' id <- c (1489221200, 1489221321, 1489221491, 136190595, 136190596)
635635#' type <- c ("node", "node", "node", "way", "way")
636636-#' datAiO <- opq_osm_id (id = id, type = type) %>%
637637-#' opq_string () %>%
636636+#' datAiO <- opq_osm_id (id = id, type = type) |>
637637+#' opq_string () |>
638638#' osmdata_sf ()
639639#' }
640640opq_osm_id <- function (id = NULL, type = NULL, open_url = FALSE,
···718718#' lon <- -3.07677
719719#' key <- "natural"
720720#' value <- "water"
721721-#' x <- opq_enclosing (lon, lat, key, value) %>%
722722-#' opq_string () %>%
721721+#' x <- opq_enclosing (lon, lat, key, value) |>
722722+#' opq_string () |>
723723#' osmdata_sf ()
724724#' }
725725#' @family queries
···782782#' key <- "amenity"
783783#' value <- "bench"
784784#' radius <- 100
785785-#' x <- opq_around (lon, lat, radius, key, value) %>%
785785+#' x <- opq_around (lon, lat, radius, key, value) |>
786786#' osmdata_sf ()
787787#' }
788788#' @family queries
···838838#'
839839#' @examples
840840#' \dontrun{
841841-#' q <- getbb ("Catalan Countries", format_out = "osm_type_id") %>%
842842-#' opq (out = "tags center", osm_type = "relation", timeout = 100) %>%
843843-#' add_osm_feature ("admin_level", "7") %>%
844844-#' add_osm_feature ("boundary", "administrative") %>%
841841+#' q <- getbb ("Catalan Countries", format_out = "osm_type_id") |>
842842+#' opq (out = "tags center", osm_type = "relation", timeout = 100) |>
843843+#' add_osm_feature ("admin_level", "7") |>
844844+#' add_osm_feature ("boundary", "administrative") |>
845845#' opq_csv (fields = c("name", "::type", "::id", "::lat", "::lon"))
846846#' comarques <- osmdata_data_frame (q) # without timeout parameter, 0 rows
847847#'
···849849#' type = "relation",
850850#' id = c ("341530", "1809102", "1664395", "343124"),
851851#' out = "tags"
852852-#' ) %>%
852852+#' ) |>
853853#' opq_csv (fields = c ("name", "name:ca"))
854854#' cities <- osmdata_data_frame (qid)
855855#' }
+12-12
R/osm-extract.R
···250250#'
251251#' @examples
252252#' \dontrun{
253253-#' tr <- opq ("trentham australia") %>% osmdata_sf ()
253253+#' tr <- opq ("trentham australia") |> osmdata_sf ()
254254#' coliban <- tr$osm_lines [which (tr$osm_lines$name == "Coliban River"), ]
255255#' pts <- osm_points (tr, rownames (coliban)) # all points of river
256256#' # the waterfall point:
···295295#'
296296#' @examples
297297#' \dontrun{
298298-#' dat <- opq ("hengelo nl") %>%
299299-#' add_osm_feature (key = "highway") %>%
298298+#' dat <- opq ("hengelo nl") |>
299299+#' add_osm_feature (key = "highway") |>
300300#' osmdata_sf ()
301301-#' bus <- dat$osm_points [which (dat$osm_points$highway == "bus_stop"), ] %>%
301301+#' bus <- dat$osm_points [which (dat$osm_points$highway == "bus_stop"), ] |>
302302#' rownames () # all OSM IDs of bus stops
303303#' osm_lines (dat, bus) # all highways containing bus stops
304304#'
305305#' # All lines which intersect with Piccadilly Circus in London, UK
306306-#' dat <- opq ("Fitzrovia London") %>%
307307-#' add_osm_feature (key = "highway") %>%
306306+#' dat <- opq ("Fitzrovia London") |>
307307+#' add_osm_feature (key = "highway") |>
308308#' osmdata_sf ()
309309#' i <- which (dat$osm_polygons$name == "Piccadilly Circus")
310310#' id <- rownames (dat$osm_polygons [i, ])
···352352#' @examples
353353#' \dontrun{
354354#' # Extract polygons which intersect Conway Street in London
355355-#' dat <- opq ("Marylebone London") %>%
356356-#' add_osm_feature (key = "highway") %>%
355355+#' dat <- opq ("Marylebone London") |>
356356+#' add_osm_feature (key = "highway") |>
357357#' osmdata_sf ()
358358#' conway <- which (dat$osm_lines$name == "Conway Street")
359359#' id <- rownames (dat$osm_lines [conway, ])
···400400#'
401401#' @examples
402402#' \dontrun{
403403-#' dat <- opq ("London UK") %>%
404404-#' add_osm_feature (key = "name", value = "Thames", exact = FALSE) %>%
403403+#' dat <- opq ("London UK") |>
404404+#' add_osm_feature (key = "name", value = "Thames", exact = FALSE) |>
405405#' osmdata_sf ()
406406#' # Get ids of lines called "The Thames":
407407#' id <- rownames (dat$osm_lines [which (dat$osm_lines$name == "The Thames"), ])
···453453#' \dontrun{
454454#' # find all multipolygons which contain the single polygon called
455455#' # "Chiswick Eyot" (which is an island).
456456-#' dat <- opq ("London UK") %>%
457457-#' add_osm_feature (key = "name", value = "Thames", exact = FALSE) %>%
456456+#' dat <- opq ("London UK") |>
457457+#' add_osm_feature (key = "name", value = "Thames", exact = FALSE) |>
458458#' osmdata_sf ()
459459#' index <- which (dat$osm_multipolygons$name == "Chiswick Eyot")
460460#' id <- rownames (dat$osm_polygons [id, ])
+2-2
R/poly2line.R
···1616#' @export
1717#' @examples
1818#' \dontrun{
1919-#' dat <- opq ("colchester uk") %>%
2020-#' add_osm_feature (key = "highway") %>%
1919+#' dat <- opq ("colchester uk") |>
2020+#' add_osm_feature (key = "highway") |>
2121#' osmdata_sf ()
2222#' # colchester has lots of roundabouts, and these are stored in 'osm_polygons'
2323#' # rather than 'osm_lines'. The former can be merged with the latter by:
+2-2
R/trim-osmdata.R
···2525#' @export
2626#' @examples
2727#' \dontrun{
2828-#' dat <- opq ("colchester uk") %>%
2929-#' add_osm_feature (key = "highway") %>%
2828+#' dat <- opq ("colchester uk") |>
2929+#' add_osm_feature (key = "highway") |>
3030#' osmdata_sf (quiet = FALSE)
3131#' bb <- getbb ("colchester uk", format_out = "polygon")
3232#' library (sf) # required for this function to work
···2525}
2626\examples{
2727\dontrun{
2828-dat <- opq ("colchester uk") \%>\%
2929- add_osm_feature (key = "highway") \%>\%
2828+dat <- opq ("colchester uk") |>
2929+ add_osm_feature (key = "highway") |>
3030 osmdata_sf ()
3131# colchester has lots of roundabouts, and these are stored in 'osm_polygons'
3232# rather than 'osm_lines'. The former can be merged with the latter by:
···2233 # elevation can't actually be tested, because it only works with a full SRTM
44 # elevation file, so this test doesn't actually do anything.
55- qry <- opq (bbox = c (-0.116, 51.516, -0.115, 51.517)) %>%
55+ qry <- opq (bbox = c (-0.116, 51.516, -0.115, 51.517)) |>
66 add_osm_feature (key = "highway")
7788 f <- file.path (tempdir (), "junk.osm")