Relations are one of the more advanced feature types to map in OpenStreetMap. Most geographic features in OpenStreetMap are represented either by points (called nodes in OpenStreetMap terminology – for example, a single tree) or lines & areas (called ways– for example, a road or park). For some more complicated features, a single node or way is not enough, and that’s when we need relations.
This building has two holes for the courtyards. How do we map them?
Imagine a building with courtyards. We can trace the building exterior as a single way, and the courtyards as two additional ways. But all three ways are part of a single building; the courtyards are “holes” within the outer polygon. This is called a multipolygon. Relations are used to model these kinds of logical or geographic relationships between features in OpenStreetMap.
Here’s how you can add a multipolygon relation in the Java OpenStreetMap Editor (JOSM):
- Draw the exterior and courtyard shapes. In this example, you would draw three ways, one outer, and two inner polygons.
- Click the
presets
menu, select therelations
sub-menu and clickmultipolygon
from the drop down. Clickadd new relation
. - You will see the relation window. Select all three polygons. You can select multiple objects by holding shift and clicking on each of them.
- Define the
Roles
for each way. You must define the exterior polygon asouter
and you must define the two courtyard polygons asinner
. Add tagsbuilding=yes
andtype=multipolygon
in the upper panel. - Click
OK
the multipolygon relation is complete.
Relations are also used for routes, boundaries, and turn restrictions. You can read more about them on the OpenStreetMap wiki, and reach out if you have any questions or tips on relations.