Relation:multipolygon/validity

From OpenStreetMap Wiki
Jump to: navigation, search

This page is only a proposition, it doesn't represent a consenus of what is or isn't valid, but only what could and couldn't be considered valid

General Rule for validity : A multipolygon relation in OSM is considered valid if it can be used, without discarding nodes or ways (or part of ways) to build a valid geometry as define by the OGC Simple Feature standard (http://www.opengeospatial.org/standards/sfs) with the notable exception of touching inner rings on 2 or more consecutiv points.

Valid multipolygon relations

A - Multipolygon in "8" shape with point at intersection

However, it is highly recommended to avoid situations where the inner and outer side change between left to right side when following the way. This ABCDEFA shape should preferably drawn as

  • AFBCDEBA (anticlockwise: the inner side is only on the left side) or alternatively as
  • ABEDCBF (clockwise: the inner side is only on the right side),

so that no part of the boundary line will pass through both sides of another part of the boundary line at the intersection node B.

A better alternative is to use solution B below, using two separate polygons.

B - Multipolygon made of two ways touching in a middle point

Simple touching outer in one point
This is the recommanded representation, using two simple closed ways intersecting only on one node.
Touching on middle way

This second example, touching on the middle of ways should preferably be avoided:
If for representing a complete ring you need to reference several ways (because they need distinct attributes or because of their complexity), you can always split these ways at the touching node and you'll use 4 ways intead of 2, so point B will be used to connect an even number of unclosed ways terminated at that point.

C - A inner ring touching the outer ring on a single point

Maybe this one is the GIS banana case
Alternatively, this may be drawn as a single polygon ABCDEFDA, where the polygon pass twice through the same point D (as in the second example below).
Simple touching outer in one point

E - 2 touching rings on single points

Invalid multipolygon relations

1 - Unclosed polygons

invalid Unclosed polygon
This is an example of an invalid multipolygon because unclosed.

2 - Overlapping, unclosed member ways belonging to the same role

invalid ambiguous multipolygon relation
This is an example of an invalid multipolygon as way #2 and way #3 endpoints share more than two ways.

3 - Self intersection without point

self intersection without point
You must explicitly add the missing intersection node, then you should preferably split the shape into two separate closed polygons touching on that point (ideally the two rings directions could be identical, both clockwise or anticlockwise but this is not required)

4 - 2 Overlapping outer-ring

2 Overlapping outer-ring

Generally this is an error caused by lack of precision where one polygon should touch another polygon on the same segments.
First add the two intersection nodes, then split the two closed ways at these nodes to create three polygons.
Finally decide on which one of the two big polygons the common central polygon should be merged into, or if the new third polygon for the central area should be removed to leave a gap between them.

5 - Polygon sharing a way with itself

The arbitrary segment used twice in reverse directions (DE then ED) should be splitted, leaving two overlapping segments.
Then remove these two superposed segments from members of the multipolygon, leaving the two rings (ABCDHA and EFGE) completely separated.
Make sure that the new EFGE closed polygon is changed from "outer" to "inner" role in the parent multipolygon).
You may then decide to drop the two superposed ways, or to merge them to a single one in the same direction if it also represents another linear feature (such as a road or wall).

See also