if (FALSE) {
q <- opq ("portsmouth usa") |>
add_osm_feature (
key = "amenity",
value = "restaurant"
) |>
add_osm_feature (key = "amenity", value = "pub")
osmdata_sf (q) # all objects that are restaurants AND pubs (there are none!)
q1 <- opq ("portsmouth usa") |>
add_osm_feature (
key = "amenity",
value = "restaurant"
)
q2 <- opq ("portsmouth usa") |>
add_osm_feature (key = "amenity", value = "pub")
c (osmdata_sf (q1), osmdata_sf (q2)) # all restaurants OR pubs
# Use of negation to extract all non-primary highways
q <- opq ("portsmouth uk") |>
add_osm_feature (key = "highway", value = "!primary")
# key negation without warnings
q3 <- opq ("Vinçà", osm_type = "node") |>
add_osm_feature (key = c ("name", "!name:ca"))
cat (opq_string (q3))
q4 <- opq ("el Carxe", osm_type = "node") |>
add_osm_feature (key = "natural", value = "peak") |>
add_osm_feature (key = "!ele")
cat (opq_string (q4))
# Get objects with keys (`natural` OR `waterway`) AND `name`
q_keys <- opq ("Badia del Vallès", osm_types = "nwr", out = "tags") |>
add_osm_features (features = list (natural = NULL, waterway = NULL)) |>
add_osm_feature (key = "name")
cat (opq_string (q_keys))
}
Run the code above in your browser using DataLab