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, without discarding nodes or ways (or part of ways) to build a valid geometry as define by the OGC Simple Feature standard ( 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
  • 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.

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
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.

See also