Empty relations

From OpenStreetMap Wiki
Jump to navigation Jump to search

Empty relations are OSM relation objects that have no members. Most time they have been created by accident. They are always bad datas. Here are some informations about relations without members and the Quality assurance hints to fix/delete empty relations.

Why are they bad datas

The main reason is a direct consequence of the definition of a relation : a relation creates a relationship, a link, a connection, between elements. If you have no member, the relation puts together nothing, assembles nothing, connects nothing, links nothing therefore it is obviously a bad data.

And what about an empty relation which is member of another relation ? This kind of relations is ok ? Of course not, an empty relation is an empty relation, it links nothing so it is also a bad data (see example 1 below).

With taginfo, we know which tags are used and for each how many are on nodes, ways and relations. An empty relation is without member but it doesn't mean it has no tags. These tags distort statistics in taginfo. For example, if you look below in the editors part, you will see than more than 3,000 empty relations were created in 2 changesets. All these relations had the same tags, type=multipolygon + natural=wood. There are more than 8 millions wood in osm databases therefore 3,000 more or less is not a big problem. But what if they had another tag, for example a proposal tag : 3,000 is huge and it could have probably influenced the vote to approve this new tag.

At the beginning of 2021, there was around 66,000 empty relations, which means probably around 200,000 bad tags in taginfo : not so much if you think how many tags there are. But probably some had rare tags and for them statistics were deeply wrong.

If someone creates an empty relation, it is like if he throws an empty plastic bottle or an empty aluminium can on a beach : just one = not a problem ? Of course it is a problem, because 1+1+1+... means pollution in osm database if nobody cares about it and fixes/deletes them.

Why are there empty relations

There are several reasons how empty relations are created. In any case it is either an error of a user, a bad import or a bug in an editor.

Created on purpose

Some users created empty relations on purpose but it is a mistake.

Example 1

A classical example is when a user reverses the use of a relation = he wants to put together some objects so he creates a relation and adds this relation to the objects (nodes/ways/relations) instead of adding the nodes/ways/relations to the relation.

For example, assume you have three roads (each modeled as a relation grouping several ways), and these roads share a common operator. You could tag the three road relations with "operator=xyz limited". But what if the operator is a more complex object consisting of a name, a telephone number and a web site ? You could think that you will create a relation with no members, tagged name=xyz limited, telephone=xxx, website=yyy, and add this relation to the 3 road relations as a member with the role "operator". But is is an error. The good way is to create a relation with the informations about the operator and add to this new relation the 3 road relations.

It is the same idea as when you create a waterway relation: you put together in one relation common tags like wikidata, wikipedia, name of the river in different languages and then add to this relation (as members) all the sections (ways) of the river.

Remember that a relation is an element "above" other objects (objects are attached to the relation), not "below" these objects (the relation should not be attached to the objects).

Example 2

A user wants to create several relations with all the tags to explain them (for example all the hiking routes that you can find on a website of a tourist center with their names, refs, links to a description of the hiking on a web site, where they begin and end and so on) and thinks "I will add the members later, there are so many". Big error: these relations with no members have no geometry (see important point about relations) so they are invisible on the map and it will be almost impossible to find them (relations are not found by loading the area where they should be present if they don't have any geolocalized members). Therefore quite impossible to add the missing members.

The good solution would have been to include at least one place node in them to geolocalise them properly, so that these relations will be loaded and visible in editors.

Relation creation without members

  • misunderstanding of what is a relation (new users, see example 1 above)
  • error of timing (see example 2 above)
  • accidental creation (bug in an editor)

These relations very often have a version number 1.

Incomplete deletions

  • A mapper removes the last member or all members (in the case of the object disappearing from the real world, for example a bus route permanently closed), but does not delete the relation itself.
  • A mapper deletes some nodes/ways (for example because they are redondant with another element) but these nodes/ways were members of a relation, the relation becomes empty and is sent empty to osm database.

Wrong merge conflict resolution

Two users edit a relation at the same time. This raises a merge conflict. Not all mappers are familiar with resolving such conflicts, and it might happen that all members are removed. The conflict resolution dialog of JOSM displays an empty member list as default. Not all users are aware of that.

Note: The object version of those relations is at least 3.

Wrong imports

Large amount of empty relations are the result of mishandled automatic imports.

What about the editors

Some editors understood for a long time that empty relations are bad datas and will prevent you from creating one:

  • iD: the iD editor automatically deletes a relation if it becomes empty because its last member was deleted. See the iD issue What to do with emptied relations. This means if you are using the iD editor, you will never create empty relations.
  • level0 : send a message "There are severe validation errors, please fix them" if you try to send an empty relation to osm database. You won't be allowed to send it until you delete the relation or add at least one member.
  • Potlatch 3: works like the iD editor, even if there is actually (Marsh 2022) a bug not easy to reproduce (see this issue).

Some other editors will warn you if you are creating an empty relation but you will be allowed to send these bad datas in the osm database:

  • JOSM: was the worst because this editor is a wonderful tool to change a lot of elements in one changeset. The problem is that sometimes JOSM created in one changeset thousands of empty relations (2010 empty relations with this changeset 106852117, 1249 with this one 106852183). A ticket has been opened to improve that but actually (Marsh 2022) the bug is still there.
  • Vespucci: don't care to create bad datas, like you can see it in this closed issue.

So be careful if you are using an editor that allows you to send these bad datas : you should fix these errors and not use the authorization given to you.

Before to fix an empty relation

The first step is to see the relation. In any web browser, use the url "https://www.openstreetmap.org/relation/NNN" where NNN is the id of the empty relation you want to look at.

The second step is to understand why the relation is empty. Some methods to do that are:

  • look at the changeset comment of the last edit. If the mapper wrote that he was doing some cleanups it's very likely that he just forgot to delete the relation.
  • look at the mapper statistics to find out whether it's a new user who might have accidentally created the relation.
  • look at the history of the relation.
  • look if there are many similar empty relations by the same user. These relations might be a result of bad imports.
  • ask the mapper who created the empty relation

Finally you can decide what to do with the relation:

  • restore old members or/and add some new
  • delete the relation
  • just do nothing if you are not sure

How to fix an empty relation

First, you need a way to access the empty relation to be able to edit it:

  • Some editors won't show an empty relation because with no member, it means no geometry so impossible to see it. For example, if you have a relation with a lot of other relations as members, some with geometry but some others empty, if you are using ID editor, when you will click on a relation with geometry, iD will show you the relation on the map, but if you click on an empty relation, nothing will happen because there is nothing to be showned.
  • Relations without members don't have a place where they are. So, you can not load them with a "bbox" selection directly in the OSM editors.

If you want to delete the relation

  • JOSM: you need to download them with the OSM API using JOSM/Plugins/RemoteControl or object download by ID.
  • Potlatch 3:
    • Select a node or a way to be used as a temporary member of the empty relation.
    • Switch to advanced view.
    • Click "Add to" below the relations list.
    • Use the "Load Relation..." to provide the relation id.
    • In the relations list, use the drop-down menu to delete the relation.
    • Answer "Yes" to the question.
  • level0 :
    • in the URL box, add the relation with r + id_of_the_empty_relation (with no space, example: r123)
    • in the bottom box, delete all the lines with a tag (keep only the line 'relation 123')
    • add a negative char ("-") at the beginning of the first line ('-relation 123')
    • add a comment for this changeset and send it to osm database

Be careful: if you delete an empty relation A which is a member of another relation B, you have to remove this relation A from the relation B. By doing this, maybe the relation B will become empty so you will have to fix/delete it too. An advice: with level0, it is impossible to create new bad datas because it will inform you that A is in the relation B (impossible to delete A until you fix B) and then that B is now empty (impossible to create an empty relation), so you will have to fix these 2 problems before to be allowed to send your changes.

If you want to restore/add members to the relation

  • with JOSM, add a node/way/relation to the empty relation you have loaded
  • with Potlatch, find the node/way/relation you want to add, follow steps 2 to 4 from the case above. Add some other elements if necessary.
  • with level0, add the empty relation (see above), then after the last line, add a new line with 2 spaces at the beginning of the line + "nd id_of_a_node role_of_the_node" or "wy id_of_a_way role_of_the_way" or "rel id_of_a_relation role_of_the_relation" (if the node/way/relation should have a role in the relation, add it. If it has no role, just add nothing). Add some other elements if necessary, one by line.

Tools : how to find empty relations

Detecting with:

  • overpass tool:

click on the link below and you will get the current empty relations.

     query with overpass-turbo

note: the result of the query is in 2 parts. First the number and the list of the empty relations not in a relation. Second the number and the list of the empty relations in at least one relation.

     osmium cat my_openstreetmap_data.osm.pbf --no-progress -t relation -f opl  |   grep " M$"

Archives

See also