2

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.

4
  • While Overpass API provides all the data for each version, overpass turbo doesn't support exporting those multiple versions as GeoJSON. That's a limitation of overpass turbo. You could split up the resulting response by version as a local post-processing step, and then convert each version to GeoJSON on its own. Basically retro already fetches the exact data at a given point in time, which is driven by the timestamps returned by timeline.
    – mmd
    Sep 23, 2021 at 14:09
  • @mmd I'm struggling to get anything out of the XML response that doesn't end up with 0 features. ogr2ogr creates 5 layers (by geometry type) all with zero features (as a geopackage). Works for an OSM file from GeoFabrik, but that has a slightly different format of XML.
    – Spacedman
    Sep 23, 2021 at 14:32
  • Yes that’s expected, out geom is an overpass API specific extension that’s incompatible with the standard osm xml format. But there are alternative ways to generate compliant xml by using (_; >>;); out meta; instead of out geom;
    – mmd
    Sep 23, 2021 at 16:32
  • @mmd if you can get that into a working Overpass Turbo query then I think we have an answer. Thanks.
    – Spacedman
    Sep 23, 2021 at 17:11

1 Answer 1

1

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.

3
  • Works! I've a hacky script to split and make valid .osm files, and then converted to .gpkg they load into QGIS okay. But I don't get the timestamp attribute from the <relation> XML tag in the attributes - might be fixable with ogr2ogr but if I rewrite my converter to properly process XML I'll maybe do it then. Thanks!
    – Spacedman
    Sep 24, 2021 at 20:22
  • 1
    Have cracked this and written it up in code and readme here: gitlab.com/b-rowlingson/get_lava so many thanks, you do get credit there!
    – Spacedman
    Oct 1, 2021 at 13:29
  • NB: Changes to ways or nodes don't automatically trigger a new version of the relation. This way some data may be missing here. See forum.openstreetmap.org/viewtopic.php?pid=844916#p844916 for discussion.
    – mmd
    Oct 24, 2021 at 10:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.