2

Hi Is there a history recorder that shows when relations were added/removed from entities?

Neither the main page history option of Deep History store such info.

asked 28 Nov '18, 14:58

DaveF's gravatar image

DaveF
1.5k576684
accept rate: 8%

The history display on the openstreetmap.org site should show changes to the members of relations, regardless of whether those members were relations or not. Can you give an example where this isn't the case?

(28 Nov '18, 17:11) alester

I was thinking of a way/node where I want to know if any relation (not a specific one where the ID is known) has been removed. History of ways/nodes on openstreetmap.org only list the current relations added to the latest edit.

(28 Nov '18, 17:51) DaveF

Oh okay, I thought you were asking about changes to the membership of relations, not the other way around. I'm not sure about any history that shows whether an object has been a member of a relation.

(28 Nov '18, 19:29) alester

It'd be very difficult to detect - a changeset that removed a way from a relation would have only the new ways of the relation in it, not the old way.

(28 Nov '18, 23:35) SomeoneElse ♦
1

Do you have an example (way/node id)? Do you have a specific use-case or question in mind?

(29 Nov '18, 16:10) ikonor

I don't have an example precisely because of this problem. I don't know whether the node/way entities previously had relations attached or not. That's what I want to discover.

(30 Nov '18, 18:57) DaveF
showing 5 of 6 show 1 more comments

2 Answers:
2

I'm also not aware of any tool that would show relation membership history for an entity. Tools like Deep History use the OSM API, but there is just the relations call that returns the current state only.

What the Overpass API can do, is getting relation memberships at a certain time in the past with the date setting and a recurse up (<):

[date:"2018-11-01T00:00:00Z"];
(
  way(id:228444126);
  <;
);
out meta geom;

Overpass Turbo

This query returns two multipolygon relations way 228444126 was part of at the time (currently none).

You can also get the diff between two timestamps (or one timestamp and current state) with the adiff setting, e.g.:

[adiff:"2018-11-01T00:00:00Z"];
way(id:228444126);
<;
out tags;

Overpass Turbo

The result is in the special Augmented Diff format (using "out tags" for brevity here).

<action type="delete">
<old>
  <relation id="2274470">
    <tag k="landuse" v="residential"/>
    <tag k="type" v="multipolygon"/>
  </relation>
</old>
<new>
  <relation id="2274470" visible="true"/>
</new>
</action>
<action type="delete">
<old>
  <relation id="3059784">
    <tag k="landuse" v="meadow"/>
    <tag k="type" v="multipolygon"/>
  </relation>
</old>
<new>
  <relation id="3059784" visible="false"/>
</new>
</action>

The actions refer to the diff between two query results at the given timestamps. So action "delete" in our context means, that two relations were found in the past but not for the current state, i.e. the way is no longer member of those two relations. The visible flag indicates that the second meadow relation was actually deleted.

Limitations:

  • net neutral changes within the given time range won't appear in the diff, e.g. if an entity was added to a relation and later removed again. Therefore searching for when an entity was removed from which relation requires knowing or figuring out a date when the entity was still a member of that relation.
  • attic data is only available since 2012-09-12T06:55:00Z
permanent link

answered 30 Nov '18, 11:56

ikonor's gravatar image

ikonor
1.1k2916
accept rate: 25%

1

Another approach is using the full history planet with the Osmium Tool OPL (Object Per Line) file format and UNIX command line tools. This is a bit more involved, but allows to retrieve the complete membership history.

Geofabrik provides full history extracts (.osh.pbf). For our example we download oberbayern-internal.osh.pbf. On the command line we further extract a bounding box for the area of interest and output as OPL format (.opl):

osmium extract --with-history --bbox 11.751,48.0832,11.8147,48.1226 -o vaterstetten.osh.opl oberbayern-internal.osh.pbf

Then we can filter for relations with the given entity in the members list using "grep". The "sed" formats the matching lines to print relation meta data and the entity member role:

ENTITY=w228444126; grep -A1 -e "^r.* M.*$ENTITY@.*" vaterstetten.osh.opl | \
  sed -e "s/^\(r.*\) i.* M.*$ENTITY@\([^,]*\).*/\1 \2/" -e "s/^\(r.*\) i.* M.*/\1 -/"

The output for way 228444126:

r2274470 v2 dV c16797536 t2013-07-02T20:43:57Z outer
r2274470 v3 dV c17398391 t2013-08-18T16:10:31Z outer
r2274470 v4 dV c64490423 t2018-11-14T16:11:18Z outer
r2274470 v5 dV c64492155 t2018-11-14T16:46:54Z -
--
r3059784 v1 dV c16797536 t2013-07-02T20:43:57Z outer
r3059784 v2 dD c64492155 t2018-11-14T16:46:54Z -

OSM files are usually ordered by type, id, version. The grep "-A1" option also prints the next line after a match or a group of consecutive matches. If that extra line is the next version of the same relation, then the entity has been removed as member, or the relation deleted ("dD"). Otherwise, if the extra line is a different relation, then the last matching version is the current and the entity still a member. The last sed expression marks those extra lines where the entity is not a member with a hyphen ("-").

permanent link

answered 02 Dec '18, 09:43

ikonor's gravatar image

ikonor
1.1k2916
accept rate: 25%

edited 02 Dec '18, 09:45

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×197
×80

question asked: 28 Nov '18, 14:58

question was seen: 578 times

last updated: 02 Dec '18, 09:45

powered by OSQA