R package for downloading OpenStreetMap data

Use base pipe |> instead of magrittr %>% in examples and tests

+166 -166
+2 -2
R/get-osmdata-df.R
··· 22 22 #' 23 23 #' @examples 24 24 #' \dontrun{ 25 - #' hampi_df <- opq ("hampi india") %>% 26 - #' add_osm_feature (key = "historic", value = "ruins") %>% 25 + #' hampi_df <- opq ("hampi india") |> 26 + #' add_osm_feature (key = "historic", value = "ruins") |> 27 27 #' osmdata_data_frame () 28 28 #' attr (hampi_df, "bbox") 29 29 #' attr (hampi_df, "overpass_call")
+2 -2
R/get-osmdata-sc.R
··· 13 13 #' 14 14 #' @examples 15 15 #' \dontrun{ 16 - #' hampi_sf <- opq ("hampi india") %>% 17 - #' add_osm_feature (key = "historic", value = "ruins") %>% 16 + #' hampi_sf <- opq ("hampi india") |> 17 + #' add_osm_feature (key = "historic", value = "ruins") |> 18 18 #' osmdata_sc () 19 19 #' 20 20 #' # Complex query as a string (not possible with regular osmdata functions)
+2 -2
R/get-osmdata-sf.R
··· 12 12 #' 13 13 #' @examples 14 14 #' \dontrun{ 15 - #' hampi_sf <- opq ("hampi india") %>% 16 - #' add_osm_feature (key = "historic", value = "ruins") %>% 15 + #' hampi_sf <- opq ("hampi india") |> 16 + #' add_osm_feature (key = "historic", value = "ruins") |> 17 17 #' osmdata_sf () 18 18 #' 19 19 #' # Complex query as a string (not possible with regular osmdata functions)
+2 -2
R/get-osmdata-sp.R
··· 20 20 #' 21 21 #' @examples 22 22 #' \dontrun{ 23 - #' hampi_sp <- opq ("hampi india") %>% 24 - #' add_osm_feature (key = "historic", value = "ruins") %>% 23 + #' hampi_sp <- opq ("hampi india") |> 24 + #' add_osm_feature (key = "historic", value = "ruins") |> 25 25 #' osmdata_sp () 26 26 #' 27 27 #' # Complex query as a string (not possible with regular osmdata functions)
+39 -39
R/opq.R
··· 69 69 #' 70 70 #' @examples 71 71 #' \dontrun{ 72 - #' q <- getbb ("portsmouth", display_name_contains = "United States") %>% 73 - #' opq () %>% 74 - #' add_osm_feature ("amenity", "restaurant") %>% 72 + #' q <- getbb ("portsmouth", display_name_contains = "United States") |> 73 + #' opq () |> 74 + #' add_osm_feature ("amenity", "restaurant") |> 75 75 #' add_osm_feature ("amenity", "pub") 76 76 #' osmdata_sf (q) # all objects that are restaurants AND pubs (there are none!) 77 - #' q1 <- getbb ("portsmouth", display_name_contains = "United States") %>% 78 - #' opq () %>% 77 + #' q1 <- getbb ("portsmouth", display_name_contains = "United States") |> 78 + #' opq () |> 79 79 #' add_osm_feature ("amenity", "restaurant") 80 - #' q2 <- getbb ("portsmouth", display_name_contains = "United States") %>% 81 - #' opq () %>% 80 + #' q2 <- getbb ("portsmouth", display_name_contains = "United States") |> 81 + #' opq () |> 82 82 #' add_osm_feature ("amenity", "pub") 83 83 #' c (osmdata_sf (q1), osmdata_sf (q2)) # all restaurants OR pubs 84 84 #' 85 85 #' # Use nodes_only to retrieve single point data only, such as for central 86 86 #' # locations of cities. 87 - #' opq <- opq (bbox, nodes_only = TRUE) %>% 88 - #' add_osm_feature (key = "place", value = "city") %>% 87 + #' opq <- opq (bbox, nodes_only = TRUE) |> 88 + #' add_osm_feature (key = "place", value = "city") |> 89 89 #' osmdata_sf (quiet = FALSE) 90 90 #' 91 91 #' # Filter by a search area 92 - #' qa1 <- getbb ("Catalan Countries", format_out = "osm_type_id") %>% 93 - #' opq (nodes_only = TRUE) %>% 92 + #' qa1 <- getbb ("Catalan Countries", format_out = "osm_type_id") |> 93 + #' opq (nodes_only = TRUE) |> 94 94 #' add_osm_feature (key = "capital", value = "4") 95 95 #' opqa1 <- osmdata_sf (qa1) 96 96 #' # Filter by a multiple search areas 97 97 #' bb <- getbb ("Vilafranca", format_out = "data.frame") 98 - #' qa2 <- bbox_to_string (bb [bb$osm_type != "node", ]) %>% 99 - #' opq (nodes_only = TRUE) %>% 98 + #' qa2 <- bbox_to_string (bb [bb$osm_type != "node", ]) |> 99 + #' opq (nodes_only = TRUE) |> 100 100 #' add_osm_feature (key = "place") 101 101 #' opqa2 <- osmdata_sf (qa2) 102 102 #' } ··· 285 285 #' 286 286 #' @examples 287 287 #' \dontrun{ 288 - #' q <- opq ("portsmouth usa") %>% 288 + #' q <- opq ("portsmouth usa") |> 289 289 #' add_osm_feature ( 290 290 #' key = "amenity", 291 291 #' value = "restaurant" 292 - #' ) %>% 292 + #' ) |> 293 293 #' add_osm_feature (key = "amenity", value = "pub") 294 294 #' osmdata_sf (q) # all objects that are restaurants AND pubs (there are none!) 295 - #' q1 <- opq ("portsmouth usa") %>% 295 + #' q1 <- opq ("portsmouth usa") |> 296 296 #' add_osm_feature ( 297 297 #' key = "amenity", 298 298 #' value = "restaurant" 299 299 #' ) 300 - #' q2 <- opq ("portsmouth usa") %>% 300 + #' q2 <- opq ("portsmouth usa") |> 301 301 #' add_osm_feature (key = "amenity", value = "pub") 302 302 #' c (osmdata_sf (q1), osmdata_sf (q2)) # all restaurants OR pubs 303 303 #' # Use of negation to extract all non-primary highways 304 - #' q <- opq ("portsmouth uk") %>% 304 + #' q <- opq ("portsmouth uk") |> 305 305 #' add_osm_feature (key = "highway", value = "!primary") 306 306 #' 307 307 #' # key negation without warnings 308 - #' q3 <- opq ("Vinçà", osm_type="node") %>% 308 + #' q3 <- opq ("Vinçà", osm_type="node") |> 309 309 #' add_osm_feature (key = c("name", "!name:ca")) 310 - #' q4 <- opq ("el Carxe", osm_type="node") %>% 311 - #' add_osm_feature (key = "natural", value = "peak") %>% 310 + #' q4 <- opq ("el Carxe", osm_type="node") |> 311 + #' add_osm_feature (key = "natural", value = "peak") |> 312 312 #' add_osm_feature (key = "!ele") 313 313 #' } 314 314 add_osm_feature <- function (opq, ··· 485 485 #' 486 486 #' @examples 487 487 #' \dontrun{ 488 - #' q <- opq ("portsmouth usa") %>% 488 + #' q <- opq ("portsmouth usa") |> 489 489 #' add_osm_features (features = list ( 490 490 #' "amenity" = "restaurant", 491 491 #' "amenity" = "pub" 492 492 #' )) 493 493 #' 494 - #' q <- opq ("portsmouth usa") %>% 494 + #' q <- opq ("portsmouth usa") |> 495 495 #' add_osm_features (features = c ( 496 496 #' "\"amenity\"=\"restaurant\"", 497 497 #' "\"amenity\"=\"pub\"" 498 498 #' )) 499 499 #' # This extracts in a single query the same result as the following: 500 - #' q1 <- opq ("portsmouth usa") %>% 500 + #' q1 <- opq ("portsmouth usa") |> 501 501 #' add_osm_feature ( 502 502 #' key = "amenity", 503 503 #' value = "restaurant" 504 504 #' ) 505 - #' q2 <- opq ("portsmouth usa") %>% 505 + #' q2 <- opq ("portsmouth usa") |> 506 506 #' add_osm_feature (key = "amenity", value = "pub") 507 507 #' c (osmdata_sf (q1), osmdata_sf (q2)) # all restaurants OR pubs 508 508 #' } ··· 620 620 #' @examples 621 621 #' \dontrun{ 622 622 #' id <- c (1489221200, 1489221321, 1489221491) 623 - #' dat1 <- opq_osm_id (type = "node", id = id) %>% 624 - #' opq_string () %>% 623 + #' dat1 <- opq_osm_id (type = "node", id = id) |> 624 + #' opq_string () |> 625 625 #' osmdata_sf () 626 626 #' dat1$osm_points # the desired nodes 627 627 #' id <- c (136190595, 136190596) 628 - #' dat2 <- opq_osm_id (type = "way", id = id) %>% 629 - #' opq_string () %>% 628 + #' dat2 <- opq_osm_id (type = "way", id = id) |> 629 + #' opq_string () |> 630 630 #' osmdata_sf () 631 631 #' dat2$osm_lines # the desired ways 632 632 #' dat <- c (dat1, dat2) # The node and way data combined 633 633 #' # All in one (same result as dat) 634 634 #' id <- c (1489221200, 1489221321, 1489221491, 136190595, 136190596) 635 635 #' type <- c ("node", "node", "node", "way", "way") 636 - #' datAiO <- opq_osm_id (id = id, type = type) %>% 637 - #' opq_string () %>% 636 + #' datAiO <- opq_osm_id (id = id, type = type) |> 637 + #' opq_string () |> 638 638 #' osmdata_sf () 639 639 #' } 640 640 opq_osm_id <- function (id = NULL, type = NULL, open_url = FALSE, ··· 718 718 #' lon <- -3.07677 719 719 #' key <- "natural" 720 720 #' value <- "water" 721 - #' x <- opq_enclosing (lon, lat, key, value) %>% 722 - #' opq_string () %>% 721 + #' x <- opq_enclosing (lon, lat, key, value) |> 722 + #' opq_string () |> 723 723 #' osmdata_sf () 724 724 #' } 725 725 #' @family queries ··· 782 782 #' key <- "amenity" 783 783 #' value <- "bench" 784 784 #' radius <- 100 785 - #' x <- opq_around (lon, lat, radius, key, value) %>% 785 + #' x <- opq_around (lon, lat, radius, key, value) |> 786 786 #' osmdata_sf () 787 787 #' } 788 788 #' @family queries ··· 838 838 #' 839 839 #' @examples 840 840 #' \dontrun{ 841 - #' q <- getbb ("Catalan Countries", format_out = "osm_type_id") %>% 842 - #' opq (out = "tags center", osm_type = "relation", timeout = 100) %>% 843 - #' add_osm_feature ("admin_level", "7") %>% 844 - #' add_osm_feature ("boundary", "administrative") %>% 841 + #' q <- getbb ("Catalan Countries", format_out = "osm_type_id") |> 842 + #' opq (out = "tags center", osm_type = "relation", timeout = 100) |> 843 + #' add_osm_feature ("admin_level", "7") |> 844 + #' add_osm_feature ("boundary", "administrative") |> 845 845 #' opq_csv (fields = c("name", "::type", "::id", "::lat", "::lon")) 846 846 #' comarques <- osmdata_data_frame (q) # without timeout parameter, 0 rows 847 847 #' ··· 849 849 #' type = "relation", 850 850 #' id = c ("341530", "1809102", "1664395", "343124"), 851 851 #' out = "tags" 852 - #' ) %>% 852 + #' ) |> 853 853 #' opq_csv (fields = c ("name", "name:ca")) 854 854 #' cities <- osmdata_data_frame (qid) 855 855 #' }
+12 -12
R/osm-extract.R
··· 250 250 #' 251 251 #' @examples 252 252 #' \dontrun{ 253 - #' tr <- opq ("trentham australia") %>% osmdata_sf () 253 + #' tr <- opq ("trentham australia") |> osmdata_sf () 254 254 #' coliban <- tr$osm_lines [which (tr$osm_lines$name == "Coliban River"), ] 255 255 #' pts <- osm_points (tr, rownames (coliban)) # all points of river 256 256 #' # the waterfall point: ··· 295 295 #' 296 296 #' @examples 297 297 #' \dontrun{ 298 - #' dat <- opq ("hengelo nl") %>% 299 - #' add_osm_feature (key = "highway") %>% 298 + #' dat <- opq ("hengelo nl") |> 299 + #' add_osm_feature (key = "highway") |> 300 300 #' osmdata_sf () 301 - #' bus <- dat$osm_points [which (dat$osm_points$highway == "bus_stop"), ] %>% 301 + #' bus <- dat$osm_points [which (dat$osm_points$highway == "bus_stop"), ] |> 302 302 #' rownames () # all OSM IDs of bus stops 303 303 #' osm_lines (dat, bus) # all highways containing bus stops 304 304 #' 305 305 #' # All lines which intersect with Piccadilly Circus in London, UK 306 - #' dat <- opq ("Fitzrovia London") %>% 307 - #' add_osm_feature (key = "highway") %>% 306 + #' dat <- opq ("Fitzrovia London") |> 307 + #' add_osm_feature (key = "highway") |> 308 308 #' osmdata_sf () 309 309 #' i <- which (dat$osm_polygons$name == "Piccadilly Circus") 310 310 #' id <- rownames (dat$osm_polygons [i, ]) ··· 352 352 #' @examples 353 353 #' \dontrun{ 354 354 #' # Extract polygons which intersect Conway Street in London 355 - #' dat <- opq ("Marylebone London") %>% 356 - #' add_osm_feature (key = "highway") %>% 355 + #' dat <- opq ("Marylebone London") |> 356 + #' add_osm_feature (key = "highway") |> 357 357 #' osmdata_sf () 358 358 #' conway <- which (dat$osm_lines$name == "Conway Street") 359 359 #' id <- rownames (dat$osm_lines [conway, ]) ··· 400 400 #' 401 401 #' @examples 402 402 #' \dontrun{ 403 - #' dat <- opq ("London UK") %>% 404 - #' add_osm_feature (key = "name", value = "Thames", exact = FALSE) %>% 403 + #' dat <- opq ("London UK") |> 404 + #' add_osm_feature (key = "name", value = "Thames", exact = FALSE) |> 405 405 #' osmdata_sf () 406 406 #' # Get ids of lines called "The Thames": 407 407 #' id <- rownames (dat$osm_lines [which (dat$osm_lines$name == "The Thames"), ]) ··· 453 453 #' \dontrun{ 454 454 #' # find all multipolygons which contain the single polygon called 455 455 #' # "Chiswick Eyot" (which is an island). 456 - #' dat <- opq ("London UK") %>% 457 - #' add_osm_feature (key = "name", value = "Thames", exact = FALSE) %>% 456 + #' dat <- opq ("London UK") |> 457 + #' add_osm_feature (key = "name", value = "Thames", exact = FALSE) |> 458 458 #' osmdata_sf () 459 459 #' index <- which (dat$osm_multipolygons$name == "Chiswick Eyot") 460 460 #' id <- rownames (dat$osm_polygons [id, ])
+2 -2
R/poly2line.R
··· 16 16 #' @export 17 17 #' @examples 18 18 #' \dontrun{ 19 - #' dat <- opq ("colchester uk") %>% 20 - #' add_osm_feature (key = "highway") %>% 19 + #' dat <- opq ("colchester uk") |> 20 + #' add_osm_feature (key = "highway") |> 21 21 #' osmdata_sf () 22 22 #' # colchester has lots of roundabouts, and these are stored in 'osm_polygons' 23 23 #' # rather than 'osm_lines'. The former can be merged with the latter by:
+2 -2
R/trim-osmdata.R
··· 25 25 #' @export 26 26 #' @examples 27 27 #' \dontrun{ 28 - #' dat <- opq ("colchester uk") %>% 29 - #' add_osm_feature (key = "highway") %>% 28 + #' dat <- opq ("colchester uk") |> 29 + #' add_osm_feature (key = "highway") |> 30 30 #' osmdata_sf (quiet = FALSE) 31 31 #' bb <- getbb ("colchester uk", format_out = "polygon") 32 32 #' library (sf) # required for this function to work
+2 -2
R/utils.R
··· 20 20 #' @family transform 21 21 #' @examples 22 22 #' \dontrun{ 23 - #' hampi_sf <- opq ("hampi india") %>% 24 - #' add_osm_feature (key = "historic", value = "ruins") %>% 23 + #' hampi_sf <- opq ("hampi india") |> 24 + #' add_osm_feature (key = "historic", value = "ruins") |> 25 25 #' osmdata_sf () 26 26 #' hampi_clean <- unname_osmdata_sf (hampi_sf) 27 27 #'
+8 -8
man/add_osm_feature.Rd
··· 65 65 66 66 \examples{ 67 67 \dontrun{ 68 - q <- opq ("portsmouth usa") \%>\% 68 + q <- opq ("portsmouth usa") |> 69 69 add_osm_feature ( 70 70 key = "amenity", 71 71 value = "restaurant" 72 - ) \%>\% 72 + ) |> 73 73 add_osm_feature (key = "amenity", value = "pub") 74 74 osmdata_sf (q) # all objects that are restaurants AND pubs (there are none!) 75 - q1 <- opq ("portsmouth usa") \%>\% 75 + q1 <- opq ("portsmouth usa") |> 76 76 add_osm_feature ( 77 77 key = "amenity", 78 78 value = "restaurant" 79 79 ) 80 - q2 <- opq ("portsmouth usa") \%>\% 80 + q2 <- opq ("portsmouth usa") |> 81 81 add_osm_feature (key = "amenity", value = "pub") 82 82 c (osmdata_sf (q1), osmdata_sf (q2)) # all restaurants OR pubs 83 83 # Use of negation to extract all non-primary highways 84 - q <- opq ("portsmouth uk") \%>\% 84 + q <- opq ("portsmouth uk") |> 85 85 add_osm_feature (key = "highway", value = "!primary") 86 86 87 87 # key negation without warnings 88 - q3 <- opq ("Vinçà", osm_type="node") \%>\% 88 + q3 <- opq ("Vinçà", osm_type="node") |> 89 89 add_osm_feature (key = c("name", "!name:ca")) 90 - q4 <- opq ("el Carxe", osm_type="node") \%>\% 91 - add_osm_feature (key = "natural", value = "peak") \%>\% 90 + q4 <- opq ("el Carxe", osm_type="node") |> 91 + add_osm_feature (key = "natural", value = "peak") |> 92 92 add_osm_feature (key = "!ele") 93 93 } 94 94 }
+4 -4
man/add_osm_features.Rd
··· 51 51 52 52 \examples{ 53 53 \dontrun{ 54 - q <- opq ("portsmouth usa") \%>\% 54 + q <- opq ("portsmouth usa") |> 55 55 add_osm_features (features = list ( 56 56 "amenity" = "restaurant", 57 57 "amenity" = "pub" 58 58 )) 59 59 60 - q <- opq ("portsmouth usa") \%>\% 60 + q <- opq ("portsmouth usa") |> 61 61 add_osm_features (features = c ( 62 62 "\"amenity\"=\"restaurant\"", 63 63 "\"amenity\"=\"pub\"" 64 64 )) 65 65 # This extracts in a single query the same result as the following: 66 - q1 <- opq ("portsmouth usa") \%>\% 66 + q1 <- opq ("portsmouth usa") |> 67 67 add_osm_feature ( 68 68 key = "amenity", 69 69 value = "restaurant" 70 70 ) 71 - q2 <- opq ("portsmouth usa") \%>\% 71 + q2 <- opq ("portsmouth usa") |> 72 72 add_osm_feature (key = "amenity", value = "pub") 73 73 c (osmdata_sf (q1), osmdata_sf (q2)) # all restaurants OR pubs 74 74 }
+13 -13
man/opq.Rd
··· 92 92 } 93 93 \examples{ 94 94 \dontrun{ 95 - q <- getbb ("portsmouth", display_name_contains = "United States") \%>\% 96 - opq () \%>\% 97 - add_osm_feature ("amenity", "restaurant") \%>\% 95 + q <- getbb ("portsmouth", display_name_contains = "United States") |> 96 + opq () |> 97 + add_osm_feature ("amenity", "restaurant") |> 98 98 add_osm_feature ("amenity", "pub") 99 99 osmdata_sf (q) # all objects that are restaurants AND pubs (there are none!) 100 - q1 <- getbb ("portsmouth", display_name_contains = "United States") \%>\% 101 - opq () \%>\% 100 + q1 <- getbb ("portsmouth", display_name_contains = "United States") |> 101 + opq () |> 102 102 add_osm_feature ("amenity", "restaurant") 103 - q2 <- getbb ("portsmouth", display_name_contains = "United States") \%>\% 104 - opq () \%>\% 103 + q2 <- getbb ("portsmouth", display_name_contains = "United States") |> 104 + opq () |> 105 105 add_osm_feature ("amenity", "pub") 106 106 c (osmdata_sf (q1), osmdata_sf (q2)) # all restaurants OR pubs 107 107 108 108 # Use nodes_only to retrieve single point data only, such as for central 109 109 # locations of cities. 110 - opq <- opq (bbox, nodes_only = TRUE) \%>\% 111 - add_osm_feature (key = "place", value = "city") \%>\% 110 + opq <- opq (bbox, nodes_only = TRUE) |> 111 + add_osm_feature (key = "place", value = "city") |> 112 112 osmdata_sf (quiet = FALSE) 113 113 114 114 # Filter by a search area 115 - qa1 <- getbb ("Catalan Countries", format_out = "osm_type_id") \%>\% 116 - opq (nodes_only = TRUE) \%>\% 115 + qa1 <- getbb ("Catalan Countries", format_out = "osm_type_id") |> 116 + opq (nodes_only = TRUE) |> 117 117 add_osm_feature (key = "capital", value = "4") 118 118 opqa1 <- osmdata_sf (qa1) 119 119 # Filter by a multiple search areas 120 120 bb <- getbb ("Vilafranca", format_out = "data.frame") 121 - qa2 <- bbox_to_string (bb [bb$osm_type != "node", ]) \%>\% 122 - opq (nodes_only = TRUE) \%>\% 121 + qa2 <- bbox_to_string (bb [bb$osm_type != "node", ]) |> 122 + opq (nodes_only = TRUE) |> 123 123 add_osm_feature (key = "place") 124 124 opqa2 <- osmdata_sf (qa2) 125 125 }
+1 -1
man/opq_around.Rd
··· 36 36 key <- "amenity" 37 37 value <- "bench" 38 38 radius <- 100 39 - x <- opq_around (lon, lat, radius, key, value) \%>\% 39 + x <- opq_around (lon, lat, radius, key, value) |> 40 40 osmdata_sf () 41 41 } 42 42 }
+5 -5
man/opq_csv.Rd
··· 33 33 } 34 34 \examples{ 35 35 \dontrun{ 36 - q <- getbb ("Catalan Countries", format_out = "osm_type_id") \%>\% 37 - opq (out = "tags center", osm_type = "relation", timeout = 100) \%>\% 38 - add_osm_feature ("admin_level", "7") \%>\% 39 - add_osm_feature ("boundary", "administrative") \%>\% 36 + q <- getbb ("Catalan Countries", format_out = "osm_type_id") |> 37 + opq (out = "tags center", osm_type = "relation", timeout = 100) |> 38 + add_osm_feature ("admin_level", "7") |> 39 + add_osm_feature ("boundary", "administrative") |> 40 40 opq_csv (fields = c("name", "::type", "::id", "::lat", "::lon")) 41 41 comarques <- osmdata_data_frame (q) # without timeout parameter, 0 rows 42 42 ··· 44 44 type = "relation", 45 45 id = c ("341530", "1809102", "1664395", "343124"), 46 46 out = "tags" 47 - ) \%>\% 47 + ) |> 48 48 opq_csv (fields = c ("name", "name:ca")) 49 49 cities <- osmdata_data_frame (qid) 50 50 }
+2 -2
man/opq_enclosing.Rd
··· 43 43 lon <- -3.07677 44 44 key <- "natural" 45 45 value <- "water" 46 - x <- opq_enclosing (lon, lat, key, value) \%>\% 47 - opq_string () \%>\% 46 + x <- opq_enclosing (lon, lat, key, value) |> 47 + opq_string () |> 48 48 osmdata_sf () 49 49 } 50 50 }
+6 -6
man/opq_osm_id.Rd
··· 72 72 \examples{ 73 73 \dontrun{ 74 74 id <- c (1489221200, 1489221321, 1489221491) 75 - dat1 <- opq_osm_id (type = "node", id = id) \%>\% 76 - opq_string () \%>\% 75 + dat1 <- opq_osm_id (type = "node", id = id) |> 76 + opq_string () |> 77 77 osmdata_sf () 78 78 dat1$osm_points # the desired nodes 79 79 id <- c (136190595, 136190596) 80 - dat2 <- opq_osm_id (type = "way", id = id) \%>\% 81 - opq_string () \%>\% 80 + dat2 <- opq_osm_id (type = "way", id = id) |> 81 + opq_string () |> 82 82 osmdata_sf () 83 83 dat2$osm_lines # the desired ways 84 84 dat <- c (dat1, dat2) # The node and way data combined 85 85 # All in one (same result as dat) 86 86 id <- c (1489221200, 1489221321, 1489221491, 136190595, 136190596) 87 87 type <- c ("node", "node", "node", "way", "way") 88 - datAiO <- opq_osm_id (id = id, type = type) \%>\% 89 - opq_string () \%>\% 88 + datAiO <- opq_osm_id (id = id, type = type) |> 89 + opq_string () |> 90 90 osmdata_sf () 91 91 } 92 92 }
+5 -5
man/osm_lines.Rd
··· 23 23 } 24 24 \examples{ 25 25 \dontrun{ 26 - dat <- opq ("hengelo nl") \%>\% 27 - add_osm_feature (key = "highway") \%>\% 26 + dat <- opq ("hengelo nl") |> 27 + add_osm_feature (key = "highway") |> 28 28 osmdata_sf () 29 - bus <- dat$osm_points [which (dat$osm_points$highway == "bus_stop"), ] \%>\% 29 + bus <- dat$osm_points [which (dat$osm_points$highway == "bus_stop"), ] |> 30 30 rownames () # all OSM IDs of bus stops 31 31 osm_lines (dat, bus) # all highways containing bus stops 32 32 33 33 # All lines which intersect with Piccadilly Circus in London, UK 34 - dat <- opq ("Fitzrovia London") \%>\% 35 - add_osm_feature (key = "highway") \%>\% 34 + dat <- opq ("Fitzrovia London") |> 35 + add_osm_feature (key = "highway") |> 36 36 osmdata_sf () 37 37 i <- which (dat$osm_polygons$name == "Piccadilly Circus") 38 38 id <- rownames (dat$osm_polygons [i, ])
+2 -2
man/osm_multilines.Rd
··· 23 23 } 24 24 \examples{ 25 25 \dontrun{ 26 - dat <- opq ("London UK") \%>\% 27 - add_osm_feature (key = "name", value = "Thames", exact = FALSE) \%>\% 26 + dat <- opq ("London UK") |> 27 + add_osm_feature (key = "name", value = "Thames", exact = FALSE) |> 28 28 osmdata_sf () 29 29 # Get ids of lines called "The Thames": 30 30 id <- rownames (dat$osm_lines [which (dat$osm_lines$name == "The Thames"), ])
+2 -2
man/osm_multipolygons.Rd
··· 24 24 \dontrun{ 25 25 # find all multipolygons which contain the single polygon called 26 26 # "Chiswick Eyot" (which is an island). 27 - dat <- opq ("London UK") \%>\% 28 - add_osm_feature (key = "name", value = "Thames", exact = FALSE) \%>\% 27 + dat <- opq ("London UK") |> 28 + add_osm_feature (key = "name", value = "Thames", exact = FALSE) |> 29 29 osmdata_sf () 30 30 index <- which (dat$osm_multipolygons$name == "Chiswick Eyot") 31 31 id <- rownames (dat$osm_polygons [id, ])
+1 -1
man/osm_points.Rd
··· 20 20 } 21 21 \examples{ 22 22 \dontrun{ 23 - tr <- opq ("trentham australia") \%>\% osmdata_sf () 23 + tr <- opq ("trentham australia") |> osmdata_sf () 24 24 coliban <- tr$osm_lines [which (tr$osm_lines$name == "Coliban River"), ] 25 25 pts <- osm_points (tr, rownames (coliban)) # all points of river 26 26 # the waterfall point:
+2 -2
man/osm_poly2line.Rd
··· 25 25 } 26 26 \examples{ 27 27 \dontrun{ 28 - dat <- opq ("colchester uk") \%>\% 29 - add_osm_feature (key = "highway") \%>\% 28 + dat <- opq ("colchester uk") |> 29 + add_osm_feature (key = "highway") |> 30 30 osmdata_sf () 31 31 # colchester has lots of roundabouts, and these are stored in 'osm_polygons' 32 32 # rather than 'osm_lines'. The former can be merged with the latter by:
+2 -2
man/osm_polygons.Rd
··· 24 24 \examples{ 25 25 \dontrun{ 26 26 # Extract polygons which intersect Conway Street in London 27 - dat <- opq ("Marylebone London") \%>\% 28 - add_osm_feature (key = "highway") \%>\% 27 + dat <- opq ("Marylebone London") |> 28 + add_osm_feature (key = "highway") |> 29 29 osmdata_sf () 30 30 conway <- which (dat$osm_lines$name == "Conway Street") 31 31 id <- rownames (dat$osm_lines [conway, ])
+2 -2
man/osmdata_data_frame.Rd
··· 37 37 } 38 38 \examples{ 39 39 \dontrun{ 40 - hampi_df <- opq ("hampi india") \%>\% 41 - add_osm_feature (key = "historic", value = "ruins") \%>\% 40 + hampi_df <- opq ("hampi india") |> 41 + add_osm_feature (key = "historic", value = "ruins") |> 42 42 osmdata_data_frame () 43 43 attr (hampi_df, "bbox") 44 44 attr (hampi_df, "overpass_call")
+2 -2
man/osmdata_sc.Rd
··· 35 35 } 36 36 \examples{ 37 37 \dontrun{ 38 - hampi_sf <- opq ("hampi india") \%>\% 39 - add_osm_feature (key = "historic", value = "ruins") \%>\% 38 + hampi_sf <- opq ("hampi india") |> 39 + add_osm_feature (key = "historic", value = "ruins") |> 40 40 osmdata_sc () 41 41 42 42 # Complex query as a string (not possible with regular osmdata functions)
+2 -2
man/osmdata_sf.Rd
··· 34 34 } 35 35 \examples{ 36 36 \dontrun{ 37 - hampi_sf <- opq ("hampi india") \%>\% 38 - add_osm_feature (key = "historic", value = "ruins") \%>\% 37 + hampi_sf <- opq ("hampi india") |> 38 + add_osm_feature (key = "historic", value = "ruins") |> 39 39 osmdata_sf () 40 40 41 41 # Complex query as a string (not possible with regular osmdata functions)
+2 -2
man/osmdata_sp.Rd
··· 31 31 } 32 32 \examples{ 33 33 \dontrun{ 34 - hampi_sp <- opq ("hampi india") \%>\% 35 - add_osm_feature (key = "historic", value = "ruins") \%>\% 34 + hampi_sp <- opq ("hampi india") |> 35 + add_osm_feature (key = "historic", value = "ruins") |> 36 36 osmdata_sp () 37 37 38 38 # Complex query as a string (not possible with regular osmdata functions)
+2 -2
man/trim_osmdata.Rd
··· 36 36 } 37 37 \examples{ 38 38 \dontrun{ 39 - dat <- opq ("colchester uk") \%>\% 40 - add_osm_feature (key = "highway") \%>\% 39 + dat <- opq ("colchester uk") |> 40 + add_osm_feature (key = "highway") |> 41 41 osmdata_sf (quiet = FALSE) 42 42 bb <- getbb ("colchester uk", format_out = "polygon") 43 43 library (sf) # required for this function to work
+2 -2
man/unname_osmdata_sf.Rd
··· 23 23 } 24 24 \examples{ 25 25 \dontrun{ 26 - hampi_sf <- opq ("hampi india") \%>\% 27 - add_osm_feature (key = "historic", value = "ruins") \%>\% 26 + hampi_sf <- opq ("hampi india") |> 27 + add_osm_feature (key = "historic", value = "ruins") |> 28 28 osmdata_sf () 29 29 hampi_clean <- unname_osmdata_sf (hampi_sf) 30 30
+26 -26
tests/testthat/test-data_frame-osm.R
··· 68 68 rownames (bb) <- c ("x", "y") 69 69 colnames (bb) <- c ("min", "max") 70 70 71 - q0 <- opq (bb, nodes_only = TRUE, datetime = "1714-09-11T00:00:00Z") %>% 71 + q0 <- opq (bb, nodes_only = TRUE, datetime = "1714-09-11T00:00:00Z") |> 72 72 add_osm_feature ("does not exist", "&%$") 73 73 74 74 osm_empty <- test_path ("fixtures", "osm-empty.osm") ··· 97 97 expect_null (meta_l$meta_no_call$query_type) 98 98 99 99 # adiff 100 - # q0 <- getbb ("Països Catalans", featuretype = "relation") %>% 100 + # q0 <- getbb ("Països Catalans", featuretype = "relation") |> 101 101 q0 <- opq ( 102 102 bb, 103 103 nodes_only = TRUE, 104 104 datetime = "1714-09-11T00:00:00Z", 105 105 adiff = TRUE 106 - ) %>% 106 + ) |> 107 107 add_osm_feature ("does not exist", "&%$") 108 108 109 109 # osm_empty <- test_path ("fixtures", "osm-empty.osm") # same result ··· 176 176 bb <- rbind (c (2.01, 2.66), c (42.42, 42.71)) 177 177 rownames (bb) <- c ("x", "y") 178 178 colnames (bb) <- c ("min", "max") 179 - q <- opq (bb, nodes_only = TRUE, datetime = "2020-11-07T00:00:00Z") %>% 180 - add_osm_feature ("natural", "peak") %>% 181 - add_osm_feature ("prominence") %>% 179 + q <- opq (bb, nodes_only = TRUE, datetime = "2020-11-07T00:00:00Z") |> 180 + add_osm_feature ("natural", "peak") |> 181 + add_osm_feature ("prominence") |> 182 182 add_osm_feature ("name:ca") 183 183 184 184 osm_meta_date <- test_path ("fixtures", "osm-date.osm") ··· 217 217 }) 218 218 219 219 test_that ("out tags center", { 220 - # q <- getbb ("Franja de Ponent", featuretype = "relation") %>% 220 + # q <- getbb ("Franja de Ponent", featuretype = "relation") |> 221 221 bb <- rbind (c (-0.73, 1.27), c (40.63, 42.63)) 222 222 rownames (bb) <- c ("x", "y") 223 223 colnames (bb) <- c ("min", "max") 224 - q <- opq (bb, out = "tags center") %>% 224 + q <- opq (bb, out = "tags center") |> 225 225 add_osm_feature ("amenity", "community_centre") 226 226 227 227 osm_tags_center <- test_path ("fixtures", "osm-tags_center.osm") ··· 249 249 }) 250 250 251 251 test_that ("out meta & diff", { 252 - # q <- getbb ("Conflent", featuretype = "relation") %>% 252 + # q <- getbb ("Conflent", featuretype = "relation") |> 253 253 bb <- rbind (c (2.01, 2.66), c (42.42, 42.71)) 254 254 rownames (bb) <- c ("x", "y") 255 255 colnames (bb) <- c ("min", "max") ··· 257 257 nodes_only = TRUE, out = "meta", 258 258 datetime = "2020-11-07T00:00:00Z", 259 259 datetime2 = "2022-12-04T00:00:00Z" 260 - ) %>% 261 - add_osm_feature ("natural", "peak") %>% 262 - add_osm_feature ("prominence") %>% 260 + ) |> 261 + add_osm_feature ("natural", "peak") |> 262 + add_osm_feature ("prominence") |> 263 263 add_osm_feature ("name:ca") 264 264 265 265 osm_meta_diff <- test_path ("fixtures", "osm-meta_diff.osm") ··· 302 302 }) 303 303 304 304 test_that ("out meta & adiff", { 305 - # q <- getbb ("Conflent", featuretype = "relation") %>% 305 + # q <- getbb ("Conflent", featuretype = "relation") |> 306 306 bb <- rbind (c (2.01, 2.66), c (42.42, 42.71)) 307 307 rownames (bb) <- c ("x", "y") 308 308 colnames (bb) <- c ("min", "max") 309 309 q <- opq (bb, 310 310 nodes_only = TRUE, out = "meta", 311 311 datetime = "2020-11-07T00:00:00Z", adiff = TRUE 312 - ) %>% 313 - add_osm_feature ("natural", "peak") %>% 314 - add_osm_feature ("prominence") %>% 312 + ) |> 313 + add_osm_feature ("natural", "peak") |> 314 + add_osm_feature ("prominence") |> 315 315 add_osm_feature ("name:ca") 316 316 317 317 osm_meta_adiff <- test_path ("fixtures", "osm-meta_adiff.osm") ··· 360 360 }) 361 361 362 362 test_that ("out tags center & adiff", { 363 - # q <- getbb ("Franja de Ponent", featuretype = "relation") %>% 363 + # q <- getbb ("Franja de Ponent", featuretype = "relation") |> 364 364 bb <- rbind (c (-0.73, 1.27), c (40.63, 42.63)) 365 365 rownames (bb) <- c ("x", "y") 366 366 colnames (bb) <- c ("min", "max") ··· 371 371 datetime2 = "2020-11-07T00:00:00Z", 372 372 adiff = TRUE, 373 373 timeout = 50 374 - ) %>% 374 + ) |> 375 375 add_osm_feature ("amenity", "community_centre") 376 376 377 377 osm_tags_center <- test_path ("fixtures", "osm-tags_center-adiff.osm") ··· 420 420 datetime = "2012-11-07T00:00:00Z", 421 421 datetime2 = "2016-11-07T00:00:00Z", 422 422 adiff = TRUE 423 - ) %>% 423 + ) |> 424 424 add_osm_feature ("amenity", "restaurant") 425 425 426 426 osm_adiff2 <- test_path ("fixtures", "osm-adiff2.osm") ··· 460 460 }) 461 461 462 462 test_that ("out:csv", { 463 - # q <- getbb ("Catalan Countries", format_out = "osm_type_id") %>% 464 - q <- opq (bbox = "relation(id:11747082)", out = "tags center", osm_type = "relation", timeout = 50) %>% 465 - add_osm_feature ("admin_level", "7") %>% 466 - add_osm_feature ("boundary", "administrative") %>% 463 + # q <- getbb ("Catalan Countries", format_out = "osm_type_id") |> 464 + q <- opq (bbox = "relation(id:11747082)", out = "tags center", osm_type = "relation", timeout = 50) |> 465 + add_osm_feature ("admin_level", "7") |> 466 + add_osm_feature ("boundary", "administrative") |> 467 467 opq_csv (fields = c ("name", "::type", "::id", "::lat", "::lon")) 468 468 469 469 with_mock_dir ("mock_csv", { ··· 473 473 r <- lapply (x, expect_is, "character") 474 474 475 475 # Test quotes and NAs 476 - # qqoutes <- getbb ("Barcelona", format_out = "osm_type_id") %>% 477 - qqoutes <- opq (bbox = "relation(id:347950)", osm_types = "nwr", out = "tags") %>% 478 - opq_csv (fields = c ("name", "::id", "no_exists", "amenity")) %>% 476 + # qqoutes <- getbb ("Barcelona", format_out = "osm_type_id") |> 477 + qqoutes <- opq (bbox = "relation(id:347950)", osm_types = "nwr", out = "tags") |> 478 + opq_csv (fields = c ("name", "::id", "no_exists", "amenity")) |> 479 479 add_osm_feature ( 480 480 key = "name", value = "\\\"|,|Pont", 481 481 value_exact = FALSE
+1 -1
tests/testthat/test-elevation.R
··· 2 2 3 3 # elevation can't actually be tested, because it only works with a full SRTM 4 4 # elevation file, so this test doesn't actually do anything. 5 - qry <- opq (bbox = c (-0.116, 51.516, -0.115, 51.517)) %>% 5 + qry <- opq (bbox = c (-0.116, 51.516, -0.115, 51.517)) |> 6 6 add_osm_feature (key = "highway") 7 7 8 8 f <- file.path (tempdir (), "junk.osm")
+1 -1
tests/testthat/test-opq.R
··· 125 125 "\"amenity\"=\"language_school\"", 126 126 "\"amenity\"=\"dancing_school\"" 127 127 ) 128 - q2 <- opq ("relation(id:349053)") %>% # "Catalunya" 128 + q2 <- opq ("relation(id:349053)") |> # "Catalunya" 129 129 add_osm_features(features = features) 130 130 s <- opq_string (q2) 131 131
+6 -6
tests/testthat/test-osmdata.R
··· 64 64 ) 65 65 expect_true (!identical (qry$bbox, qry6$bbox)) 66 66 67 - qry7 <- opq ("relation(id:74310)") %>% # "Vinçà" 67 + qry7 <- opq ("relation(id:74310)") |> # "Vinçà" 68 68 add_osm_feature (key = c("name", "!name:ca")) 69 - qry8 <- opq ("relation(id:11755232)") %>% # "el Carxe" 70 - add_osm_feature (key = "natural", value = "peak") %>% 69 + qry8 <- opq ("relation(id:11755232)") |> # "el Carxe" 70 + add_osm_feature (key = "natural", value = "peak") |> 71 71 add_osm_feature (key = "!ele") 72 72 expect_warning( 73 - qry9 <- opq ("relation(id:11755232)") %>% # "el Carxe" 74 - add_osm_feature (key = "!ele")%>% 73 + qry9 <- opq ("relation(id:11755232)") |> # "el Carxe" 74 + add_osm_feature (key = "!ele")|> 75 75 add_osm_feature (key = "natural", value = "peak"), 76 76 "The query will request objects whith only a negated key " 77 77 ) ··· 184 184 "`out meta` queries not yet implemented." 185 185 ) 186 186 187 - qcsv <- opq (bbox = c (1.8374527, 41.5931579, 1.8384799, 41.5936434)) %>% 187 + qcsv <- opq (bbox = c (1.8374527, 41.5931579, 1.8384799, 41.5936434)) |> 188 188 opq_csv(fields = c("name")) 189 189 expect_error ( 190 190 osmdata_xml (q = qcsv),
+2 -2
tests/testthat/test-trim.R
··· 79 79 ) 80 80 x1 <- trim_osmdata (x0, bb, exclude = FALSE) 81 81 82 - bb_sf <- sf::st_polygon (list (bb)) %>% 83 - st_sfc () %>% 82 + bb_sf <- sf::st_polygon (list (bb)) |> 83 + st_sfc () |> 84 84 st_sf () 85 85 expect_silent (x2 <- trim_osmdata (x0, 86 86 bb_poly = bb_sf,