Open vanhry opened 2 years ago
Thanks @vanhry, that's an interesting question. timestamps of individual objects are not by default delivered by the overpass server, but can be extracted as "metadata" as in your query above. Getting a local copy of the raw + metadata can be done by modifying your example like this:
q <- opq("London",timeout = 20000) %>%
add_osm_feature(key = "landuse", value="grass",value_exact = F) %>%
opq_string()
q <- gsub("out body", "out body meta", q)
filename <- "mydata.osm"
x <- osmdata_xml(q, filename = filename)
You'll then see the timestamps (and other metadata) appear alongside each object. The file can still be read directly with osmdata_sf()
, but those metadata can not be converted into equivalent data columns in the sf objects, because there is no direct translation between OSM and sf objects. It might be tempting to think that the meta
statement shown above might translate nicely to some kind of meta = FALSE
parameter which could be switched on to get these data, but:
sf
objects.A more workable alternative might be to utilise the ::timestamp
data accessible via the csv output mode, as is currently under discussion in #252. I suggest leaving this issue open for the moment, and I'll return to it as part of addressing that broader issue. Once some kind of osmdata_csv()
function has been developed, that will then allow simple queries taking OSM ID values as inputs and returning timestamps as outputs. In the context of your example, you'll get the standard output from your searchArea
query above as delivered with the last line of out body
, and then be able to use the resultant ID values to get any desired bits of out meta
. Happy to discuss any other ideas you might have until then.
Thanks @mpadge, You helped me a lot!
If #285 is accepted, I can work on implementing different out modes such as meta
, tags
and others. Can be useful to select objects based on tags and metadata and then download the spatial data based on OSM type and ID now that #283 is working.
Almost ready for a PR at https://github.com/jmaspons/osmdata/commit/83148a929586459760dd0483f28f640f96e7b858 . Waiting for #285
When I query osm data, I want to receive the timestamp, when some object was added or changed, is it possible to include this data? There is my query:
Then I use
q$osm_polygons
data.in general, I want to convert this script to R: