Getting OSM features by ID at a version number

apiopenstreetmapoverpass-api

The lava flow from the eruption in the Canary Islands is being shown on OpenStreetMap. It has OSM ID 13249829 and is being updated, and various revisions are in OSM, as can be seen via this API call:

https://www.openstreetmap.org/api/0.6/relation/13249829/history

How can I get the full geometry of this relation at the time of the revision? The XML history links to ways, so somehow I'd have to get the ways by ID at the time of the revision, and it looks like I'd have to do that by referring to the changeset at that point, and then I get bogged down in the complications… Is there an API that can do all this? I can't see how from the OSM API or from OverPass but I may be missing something.

This is close:

timeline(rel, 13249829);
foreach(
  retro(u(t["created"]))
  (
    rel(13249829);
    out meta geom;
  );
);

but when run from https://overpass-turbo.eu/ the downloaded GeoJSON only has the latest version, and the download OSM XML presents to OGR/GDAL with no features, although the coordinates of all versions seem to be in there. https://overpass-turbo.eu/s/1bqH if you want to try yourself.

Related Q's on here nearly always refer to getting data at a date point, but I want to get data at a known set of revisions for a relation. Perhaps getting the date of the revision and then querying by date is the solution?

Note: I could get the data from the Copernicus site [https://emergency.copernicus.eu/mapping/list-of-components/EMSR546] but would like to know if I can do this via OSM.

Best Answer

While it's possible to fetch all relation versions along with their respective nodes and ways in a query similar to your example, Overpass turbo doesn't support exporting multiple object versions in GeoJSON.

To use this data in downstream processing, you would have to split the result produced by the following query after each "relation" element:

timeline(rel, 13249829);
foreach(
  retro(u(t["created"]))
  (
    (rel(13249829);>>;);
    out meta;
    
  );
);

The XML result adheres to the following structure:

 ... nodes and ways versions used by relation version 1...
 ... ways versions used by relation version 1...
 ... relation 1 ...

    <--- ( split result by version ) --->

 ... nodes and ways versions used by relation version 2...
 ... ways versions used by relation version 2...
 ... relation 2 ...

 (and so forth)

In a post processing step, you would need to split the result as indicated above.