osmdata (version 0.0.1)

add_feature: Add a feature to an Overpass query

Description

Add a feature to an Overpass query

Usage

add_feature(opq, key, value, key_exact = TRUE, value_exact = TRUE,
  match_case = TRUE, bbox = NULL)

Arguments

opq

An overpass_query object

key

feature key

value

value for feature key; can be negated with an initial exclamation mark, value="!this".

key_exact
value_exact

If FALSE, value is not interpreted exactly

match_case

If FALSE, matching for both key and value is not sensitive to case

bbox

optional bounding box for the feature query; must be set if no opq query bbox has been set

Value

opq object

References

http://wiki.openstreetmap.org/wiki/Map_Features

Examples

Run this code

q <- getbb ("portsmouth", display_name_contains="United States") %>% opq () %>% 
        add_feature("amenity", "restaurant") %>%
        add_feature("amenity", "pub") 
osmdata_sf (q) # all objects that are restaurants AND pubs (there are none!)
q1 <- getbb ("portsmouth", display_name_contains="United States") %>% opq () %>% 
        add_feature("amenity", "restaurant") 
q2 <- getbb ("portsmouth", display_name_contains="United States") %>% opq () %>% 
        add_feature("amenity", "pub") 
c (osmdata_sf (q1), osmdata_sf (q1)) # all objects that are restaurants OR pubs
# Use of negation to extract all non-primary highways
q <- opq ("portsmouth uk") %>% add_feature (key="highway", value="!primary") 

Run the code above in your browser using DataLab