Learn R Programming

osmdata (version 0.2.3)

opq_csv: 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)

Value

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

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.

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

Run this code
if (FALSE) {
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)
}

Run the code above in your browser using DataLab