Relation member references non-existing way

I’m attempting to render an extract from https://www.openstreetmap.org, but I’m struggling with how to process multipolygon relations.

During debugging I noticed that some of the members have references to non-existing ways.

<relation id="5865323" version="1" timestamp="2016-01-15T19:30:46Z" changeset="36600695" uid="3296383">
    <member type="way" ref="391638537" role="outer"/>

A search through the XML-document found only one occurrence of the ref (391638537), which was for the member. How do I handle this? Am I working on corrupt data?

Essentially two points:

a) if all relation members are included depends on how the extract you are using was created.

b) all OSM data processing software needs to deal with relation members that are not present in some way (preferably not crashing)

Note that it is even a bit more complicated with history data, but I assume that is not what you are using.

Simon

I was using the extract-functionality on the OSM webpage, by setting a bounding rectangle. I see that the relation on the OSM map has all required data, but it somehow did not get downloaded. http://www.openstreetmap.org/relation/5865323

It doesn’t crash, but the rendered result is malformed. I’ll add validation step after the initial import and download any missing nodes/ways as they appear missing. Is there an API or link that can be constructed to query specific node/ways by ID? Can Overpass do this?

Just found out individual nodes and ways can be downloaded like this.

http://www.openstreetmap.org/api/0.6/node/3948587977
and
http://www.openstreetmap.org/api/0.6/way/391638537

Thanks for the input Simon, I think I got it sorted out. Still curious as to why some data is left out during the export, though.

Yes.

It can simply be very expensive, as relations can be very large and have lots (really lots) of members (not even thinking of that you actually have to do this recursively to really get “everything”).

Imagine extracting anything that say has a bit of the US border in it, or one of those very large landuse multi-polygons.

Thanks!

That’s a fair point. However it would be handy to be notified of any left-out nodes or ways at time of export. I guess it will be hard to validate the downloaded XML, though. I also came across this just now, that this (the browser ‘export’) has limitations in terms of the size and complexity of the data you can request., and under the export-button some alternatives if exporting fails.