This is an API method for querying changesets. It supports querying by different criteria.
osm_query_changesets(
bbox,
user,
time,
time_2,
from,
to,
open,
closed,
changeset_ids,
order = c("newest", "oldest"),
limit = getOption("osmapir.api_capabilities")$api$changesets["default_query_limit"],
format = c("R", "sf", "xml", "json"),
tags_in_columns = FALSE
)
If format = "R"
, returns a data frame with one OSM changeset per row. If format = "sf"
, returns a sf
object
from sf.
format = "xml"
Returns a xml2::xml_document with the following format:
<osm version="0.6" generator="OpenStreetMap server" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/">
<changeset id="10" created_at="2005-05-01T16:09:37Z" open="false" comments_count="1" changes_count="10" closed_at="2005-05-01T17:16:44Z" min_lat="59.9513092" min_lon="10.7719727" max_lat="59.9561501" max_lon="10.7994537" uid="24" user="Petter Reinholdtsen">
<tag k="created_by" v="JOSM 1.61"/>
<tag k="comment" v="Just adding some streetnames"/>
...
</changeset>
<changeset ...>
...
</changeset>
</osm>
format = "json"
Please note that the JSON format has changed on August 25, 2024 with the release of openstreetmap-cgimap 2.0.0, to align it with the existing Rails format.
Returns a list with the following json structure:
{
"version": "0.6",
"generator": "openstreetmap-cgimap 2.0.0 (4003517 spike-08.openstreetmap.org)",
"copyright": "OpenStreetMap and contributors",
"attribution": "http://www.openstreetmap.org/copyright",
"license": "http://opendatacommons.org/licenses/odbl/1-0/",
"changesets": [
{
"id": 10,
"created_at": "2005-05-01T16:09:37Z",
"open": false,
"comments_count": 1,
"changes_count": 10,
"closed_at": "2005-05-01T17:16:44Z",
"min_lat": 59.9513092,
"min_lon": 10.7719727,
"max_lat": 59.9561501,
"max_lon": 10.7994537,
"uid": 24,
"user": "Petter Reinholdtsen",
"tags": {
"comment": "Just adding some streetnames",
"created_by": "JOSM 1.61"
}
},
...
]
}
Find changesets within the given bounding box coordinates (left,bottom,right,top
).
Find changesets by the user with the given user id (numeric) or display name (character).
Find changesets closed after this date and time. See details for the valid formats.
find changesets that were closed after time
and created before time_2
. In other words, any
changesets that were open at some time during the given time range time
to time_2
. See details for the
valid formats.
Find changesets created at or after this value. See details for the valid formats.
Find changesets created before this value. to
requires from
, but not vice-versa. If to
is
provided alone, it has no effect. See details for the valid formats.
If TRUE
, only finds changesets that are still open but excludes changesets that are closed or have
reached the element limit for a changeset (10,000 at the moment osm_capabilities()$api$changesets
).
If TRUE
, only finds changesets that are closed or have reached the element limit.
Finds changesets with the specified ids.
If "newest"
(default), sort newest changesets first. If "oldest"
, reverse order.
Specifies the maximum number of changesets returned. 100 as the default value.
Format of the output. Can be "R"
(default), "sf"
, "xml"
, or "json"
.
If FALSE
(default), the tags of the changesets are saved in a single list column tags
containing a data.frame
for each changeset with the keys and values. If TRUE
, add a column for each key.
Ignored if format != "R"
.
Where multiple queries are given the result will be those which match all of the requirements. The contents of the
returned document are the changesets and their tags. To get the full set of changes associated with a changeset, use
osm_download_changeset()
on each changeset ID individually.
Modification and extension of the basic queries above may be required to support rollback and other uses we find for changesets.
This call returns latest changesets matching criteria. The default ordering is newest first, but you can specify
order = "oldest"
to reverse the sort order (see
ordered by created_at
– see the current state).
Reverse ordering cannot be combined with time
.
Te valid formats for time
, time_2
, from
and to
parameters are POSIXt values or characters with anything
that Time.parse
Ruby function will
parse.
Other get changesets' functions:
osm_download_changeset()
,
osm_get_changesets()
chst_ids <- osm_query_changesets(changeset_ids = c(137627129, 137625624))
chst_ids
chsts <- osm_query_changesets(
bbox = c(-1.241112, 38.0294955, 8.4203171, 42.9186456),
user = "Mementomoristultus",
time = "2023-06-22T02:23:23Z",
time_2 = "2023-06-22T00:38:20Z"
)
chsts
chsts2 <- osm_query_changesets(
bbox = c("-9.3015367,41.8073642,-6.7339533,43.790422"),
user = "Mementomoristultus",
closed = TRUE
)
chsts2
Run the code above in your browser using DataLab