add_osm_features: Add multiple features to an Overpass query

add_osm_featuresR Documentation

Add multiple features to an Overpass query

Description

Alternative version of add_osm_feature for creating single queries with multiple features. Key-value matching may be controlled by using the filter symbols described in https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#By_tag_.28has-kv.29.

Usage

add_osm_features(
  opq,
  features,
  bbox = NULL,
  key_exact = TRUE,
  value_exact = TRUE
)

Arguments

opq

An overpass_query object

features

A named list or vector with the format list("<key>" = "<value>") or c("<key>" = "<value>") or a character vector of key-value pairs with keys and values enclosed in escape-formatted quotations. See examples for details.

bbox

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

key_exact

If FALSE, key is not interpreted exactly; see https://wiki.openstreetmap.org/wiki/Overpass_API

value_exact

If FALSE, value is not interpreted exactly

Value

opq object

add_osm_feature vs add_osm_features

Features defined within an add_osm_features call are combined with a logical OR.

Chained calls to either add_osm_feature or add_osm_features() combines features from these calls in a logical AND; this is analagous to chaining dplyr::filter() on a data frame.

add_osm_features() with only one feature is logically equivalent to add_osm_feature().

References

https://wiki.openstreetmap.org/wiki/Map_Features

See Also

add_osm_feature

Other queries: add_osm_feature(), bbox_to_string(), getbb(), opq_around(), opq_csv(), opq_enclosing(), opq_osm_id(), opq_string(), opq(), overpass_status()

Examples

## Not run: 
q <- opq ("portsmouth usa") %>%
    add_osm_features (features = list (
        "amenity" = "restaurant",
        "amenity" = "pub"
    ))

q <- opq ("portsmouth usa") %>%
    add_osm_features (features = c (
        "\"amenity\"=\"restaurant\"",
        "\"amenity\"=\"pub\""
    ))
# This extracts in a single query the same result as the following:
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

## End(Not run)

osmdata documentation built on Aug. 14, 2023, 5:08 p.m.