Add a feature to an Overpass query
add_osm_feature( opq, key, value, key_exact = TRUE, value_exact = TRUE, match_case = TRUE, bbox = NULL )
opq | An |
---|---|
key | feature key |
value | value for feature key; can be negated with an initial
exclamation mark, |
key_exact | If FALSE, |
value_exact | If FALSE, |
match_case | If FALSE, matching for both |
bbox | optional bounding box for the feature query; must be set if no opq query bbox has been set |
opq object
key_exact
should generally be TRUE
, because OSM uses a
reasonably well defined set of possible keys, as returned by
available_features. Setting key_exact = FALSE
allows matching
of regular expressions on OSM keys, as described in Section 6.1.5 of
https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL. The actual
query submitted to the overpass API can be obtained from
opq_string.
https://wiki.openstreetmap.org/wiki/Map_Features
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") }