opq_csv: Transform an Overpass query to return the result in a csv...

opq_csvR Documentation

Transform an Overpass query to return the result in a csv format

Description

Transform an Overpass query to return the result in a csv format

Usage

opq_csv(q, fields, header = TRUE)

Arguments

q

A opq string or an object of class overpass_query constructed with opq or alternative opq builders (+ add_osm_feature/s).

fields

a character vector with the field names.

header

if FALSE, do not ask for column names.

Details

The output format csv, ask for results in csv. See CSV output mode for details. To get the data, use osmdata_data_frame.

Value

The overpass_query or string with the prefix changed to return a csv.

Note

csv queries that reach the timeout will return a 0 row data.frame without any warning. Increase timeout in q if you don't see the expected result.

See Also

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

Examples

## Not run: 
q <- getbb ("Catalan Countries", format_out = "osm_type_id") %>%
    opq (out = "tags center", osm_type = "relation", timeout = 100) %>%
    add_osm_feature ("admin_level", "7") %>%
    add_osm_feature ("boundary", "administrative") %>%
    opq_csv (fields = c("name", "::type", "::id", "::lat", "::lon"))
comarques <- osmdata_data_frame (q) # without timeout parameter, 0 rows

qid<- opq_osm_id (
    type = "relation",
    id = c ("341530", "1809102", "1664395", "343124"),
    out = "tags"
) %>%
    opq_csv (fields = c ("name", "name:ca"))
cities <- osmdata_data_frame (qid)

## End(Not run)

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