Area
An area (or filled polygon) is a two-dimensional object bounded by one or more linear ways and marked by appropriate tags. The simplest areas are defined by closed ways, having the same start and end node. More complex areas are defined using multipolygon relations, which may specify multiple boundary ways.
Areas are not distinct data primitives in the OpenStreetMap model, and whether a closed way is an area is inferred from its tags. For example, ways tagged with landuse=* are assumed to be areas, but ways tagged as highway=pedestrian are treated as linear features, unless they have an explicit area=yes tag, describing a pedestrian area.
How to map
There are two ways to create an area:
- For smaller areas is it often appropriate to create a single closed way with suitable tags and in some rare cases it is also necessary to add area=yes. See area=* for further details.
- For larger areas and for ones which butt up to other areas or to ways is it often more appropriate to use a multipolygon, again tagged as required. See Relation:multipolygon for more details.
Although multipolygons are technically relations , their usage is generally accepted for tags that only list usage on areas (and for which the wiki states these tags should NOT be used on relations). This is an exception since multipolygons are relations specifically meant to represent areas (polygons). For instance: natural=* is used 2,5 million times on relations; landuse=* 1,8 million times (as per Taginfo, 2023).
Closed ways with some combinations of tags can create both a linear 'closed polygon' and also an area. For example a roundabout with a grass area in the middle might defined as a closed way tagged with highway=primary and also with landuse=grass. This would be interpreted as a circular cased road with a green areas in the middle.
When rendering ways with tags which can only be used with closed ways, ways that are not closed will often be 'closed' by joining their ends so that the area can then be filled.
In the past it was necessary to draw boundaries around areas in a particular direction (clockwise or anticlockwise) to ensure that the information was rendered properly - that is no longer necessary.
Presentation
When drawn, smaller areas are in general drawn 'on top' of larger areas which ensures that a small wood in a large park appears as a wood in a park.
However, in situations where there are actually holes in the larger feature, such as with a grass clearing in a wood, multipolygons should be used to explicitly specify e.g. the clearing in the wood and separately define the grass area in that clearing.
Examples
Simple area
In this example a lake is defined by a closed way where the last node equals the first of the way. The use of natural=water implies area=yes. Note that it is not possible to describe lake surfaces having islands or islets this way, as closed ways, by definition, cannot have holes.
<way id="4876027" timestamp="2008-03-12T07:59:11Z" user="MichaelCollinson">
<nd ref="31492372"/>
<nd ref="31492338"/>
<nd ref="31492370"/>
<nd ref="31492371"/>
<nd ref="31492372"/>
<tag k="natural" v="water"/>
<tag k="name" v="Spegeldammen"/>
</way>
Multipolygon area
Areas may also be defined with relation:multipolygon as a set of ways which define one or more outer boundaries, and optionally zero or more inner boundaries ('holes'). In the example below there is one outer boundary defined by a single way, and two ways as inner:
From the data fragment alone we cannot tell if these are
- two holes (both ways are closed ways, upper picture to the right) or
- one hole (both inner ways concatenated form a closed way, lower picture to the right)
This is resolved by looking at the data of #8125153 and #8125154 respectively.
<relation id="12" timestamp="2008-12-21T19:31:43Z" user="kevjs1982" uid="84075">
<member type="way" ref="2878061" role="outer"/> <!-- picture ref="1" -->
<member type="way" ref="8125153" role="inner"/> <!-- picture ref="2" -->
<member type="way" ref="8125154" role="inner"/> <!-- picture ref="3" -->
<member type="way" ref="3811966" role=""/> <!-- empty role produces
a warning; avoid this; most software works around it by computing
a role, which is more expensive than having one set explicitly;
not shown in the sample pictures to the right -->
<tag k="type" v="multipolygon"/>
</relation>
Tags implying area status
Areas can be created explicitly with multipolygons or by adding area=yes, but several tags on closed way also imply that it is an area - or not. For example landuse=forest clearly means tree-covered area, not row of trees. While natural=tree_row on a closed way clearly means that it is a ring of trees.
area=no may be used to explicitly override default assumptions, it is usable in some rare cases such as bench mapped as a line that forms a closed way (see an example example).
Different software processing OSM tags will have their own lists that may subtly differ, in large part due to different ways how these lists are used.
- JOSM - has AreaTags function
- StreetComplete - IS_AREA_EXPR
- iD - osmlab/id-area-keys/blob/main/areaKeys.json GitHub (keys list what is considered as an area, listed values are exceptions from such rules. So
"military": {"trench": true},")
means that all tags with military=* are considered as area tags, with exception of military=trench). - Osmtogeojson - _isPolygonFeature function
- OSHDB - GIScience/oshdb/blob/master/oshdb-util/src/main/resources/json/polygon-features.json GitHub
- GDAL PBF driver - https://github.com/OSGeo/gdal/blob/master/data/osmconf.ini#L7
- https://github.com/osmcode/osmium-surplus/blob/master/filter-patterns/polygon-tags
- See also: Overpass API/Areas
Note that processing is complicated and is likely to break down in case of representing multiple objects with one geometry element. For example, representing both playground and wall around a playground on one element (barrier=wall and leisure=playground) will cause problems in case of attempts to render wall as areas. See for example case of a default map style.
See also
- The Future of Areas
- Overpass turbo/Polygon Features - the implementation in Overpass turbo may be useful as a starting point for developers
- area=* - Used to mark that a specific feature is a general area (only used for closed way objects, not used for nodes, open ways and relations).
|