Learn R Programming

osmdata (version 0.4.1)

filter_osm_user: Add an user filter to an Overpass query

Description

Select objects last edited or ever touched by a specific user.

Usage

filter_osm_user(opq, user, touched = FALSE, is_uid)

Value

An opq object.

Arguments

opq

An overpass_query object.

user

A vector of user names or user ids. If is.numeric(user) or all(grepl(^[0-9]+$, user)), assumes that user is a user id.

touched

If TRUE, selects objects of which at least one version has been edited by user. If FALSE (default), selects objects with user as the last editor only.

is_uid

If FALSE, assume that user are user names. Useful to filter for a user name which contains numbers only and otherwise would be considered an user id.

Details

The order of filter_osm_user() in a query construction is not relevant and is applied to the whole query (i.e. it affects all the statements of the query).

See https://dev.overpass-api.de/overpass-doc/en/criteria/misc_criteria.html#by_user for details.

See Also

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

Examples

Run this code
# Notice the "::user" and "::uid" fields in the opq_csv()
q_csv <- opq (bbox = "relation(id:11755232)", out = "meta", osm_type = "node") |>
    filter_osm_user (user = "jmaspons") |>
    add_osm_feature (key = "name") |>
    opq_csv (c ("::type", "::id", "name", "name:ca", "::user", "::uid"))
cat (opq_string (q_csv))
# Warning: csv queries can fail without errors in long running queries. For timeouts,
# it returns empty results.
if (FALSE) {
d_csv <- osmdata_data_frame (q_csv)
d_csv
}

q_touched <- opq (
    bbox = "relation(id:11755232)", out = "meta",
    osm_type = "node", timeout = 100
) |>
    filter_osm_user (user = "jmaspons", touched = TRUE) |>
    add_osm_feature (key = "name")
cat (opq_string (q_touched))
if (FALSE) {
d_touched <- osmdata_data_frame (q_touched)
d_touched
}

Run the code above in your browser using DataLab