Relation:multipolygon/validity

From OpenStreetMap Wiki
Jump to navigation Jump to 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 to build a valid geometry as define by the OGC Simple Feature standard (http://www.opengeospatial.org/standards/sfs) without:

  •       discarding nodes or ways (or part of ways)  with the notable exception of touching inner rings on 2 or more consecutive points,
  •       splitting ways and rearranging them to another ring structure.

Notable exception: touching inner rings on 2 or more consecutiv points.

One should be aware that OGC distinguishes between polygon and multipolygon, the latter being a collection of polygons.  Building a valid OGC-geometry from an OSM-multipolygon therefore means that each outer boundary with its corresponding inner boundaries  should build a valid OGC-polygon.

This means that the (implicit) polygons as part of a OSM-MP should conform to these rules as defined in the Geometry object model (Simple Feature Access - Part 1: Common Architecture):

  • a) Polygons are topologically closed;
  • b) The boundary of a Polygon consists of a set of LinearRings that make up its exterior and interior boundaries;
  • c) No two Rings in the boundary cross and the Rings in the boundary of a Polygon may intersect at a Point but only as a tangent, e.g. ∀ P ∈ Polygon, ∀ c1,c2∈P.Boundary(), c1≠c2, ∀ p, q ∈Point, p, q ∈ c1, p ≠ q , [p ∈ c2] ⇒ [∃ δ > 0 ∋ [|p-q|<δ] ⇒ [q ∉ c2] ]; Note: This last condition says that at a point common to the two curves, nearby points cannot be common. This forces each common point to be a point of tangency.
  • d) A Polygon may not have cut lines, spikes or punctures e.g.: ∀ P ∈ Polygon, P = P.Interior.Closure;
  • e) The interior of every Polygon is a connected point set;
  • f) The exterior of a Polygon with 1 or more holes is not connected. Each hole defines a connected component of the exterior.

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
  • ABEDCBFA (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


Either orientation does not lead to a valid OGC-polygon because the interior is not connected (OGC-rule e)).


Therefore 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 because it cannot be converted to a valid OGC-multiploygon:
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).


Valid polygon morphed into an invalid polygon
However there is a problem using a single closed ring like ABCDFEGDHA in this example: if the boundary is morphed by moving F onto the line BC the result is NOT a valid OGC-polygon, because the interior is no longer connected. If editing is done in a box including points E, F and B only (not including any of the other points), the mapper will not be aware of that problem.
Simple touching outer in one point
You may also split this single way in two parts on point D to create a multipolygon: way DCBAGD will be an outer member of the multipolygon, and way DEFD will be an inner member as in the first figure.

E - 2 touching rings on single points

These two ways that are outer members of the multipolygon may also be replaced by two other ways: one larger outer way ignoring the borders of the central hole, and an inner way passing along these borders, where both ways pass through the same two isolated nodes.

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 the startpoint or endpoint of way #2 and way #3 actually share an odd number (three) of ways (ways #1, #2 and #3 for one point, or ways #2, #3 and #4 for the second point).

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 of the two big polygons you should merge the overlapping central area, or if a separate 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 central closed polygon EFGE is changed from "outer" to "inner" role in the parent multipolygon.
You may then decide to drop the two superposed ways (DE and ED), or to keep only one of them (in the appropriate direction where needed) if it also represents another linear feature (such as a road or wall) with other distinctive tags.

6 - „Forest with lake with forest on island in lake“

Cascading polygons.png
"cascading" polygons
The interior (green) is not connected, so this violates OGC rule e))


See also