Dual tagging

From OpenStreetMap Wiki
Jump to navigation Jump to search

Dual tagging is the practice of assigning multiple top-level tags to a single element, either to better describe a real-world feature or to simplify the representation of multiple real-world features.

Hybrid features

Sometimes an element represents a hybrid feature that does not neatly fit into the definition of one of the top-level tags. The "One feature, one OSM element" principle is interpreted as requiring a single element for both aspects of the feature. For example, a restaurant that also offers catering services may be tagged as amenity=restaurant craft=caterer.

Unfortunately, sometimes the two top-level tags are associated with the same key, for example, shop=wine and shop=cheese for a single, undifferentiated wine-and-cheese shop. In this case, some mappers pick one of the top-level tags and ignore the other, while other mappers combine shop=wine;cheese using the multiple values syntax, and still others map two separate elements, violating the "One feature, one element" principle as a tradeoff for broader compatibility. Separating it into two separate elements also has the advantage of more easily expressing partial conditions, such as more limited opening_hours=* for wine sales than cheese sales.

Coextensive features

Sometimes multiple distinct features are spatially coextensive, so they are represented by a single element for simplicity. For example, some mappers prefer to map a cheese shop that occupies an entire building as a single building=retail shop=cheese area. This affirms that the shop does occupy the entire building, as opposed to a situation in which the building has other unmapped occupants.

Nevertheless, as more secondary detail is added to the element, it may become necessary to separate the element into multiple elements, each with its own top-level tag. If the cheese shop occupies a heritage=* building that has its own name, or if it turns out that the building's upper level is a residential loft, then the shop becomes a separate shop=cheese point within the building area, or perhaps a shop=cheese area sharing all of the building area's nodes, forming the basis for future indoor mapping. Some secondary attributes like the address may end up duplicated across these elements.

Advantages and disadvantages

Merging features into a common element can make it easier for a data consumer to discover explicit relationships between the real-world features without resorting to spatial queries and heuristics based on regional assumptions.

On the other hand, an editor or data consumer might process the element unpredictably, since technically all of an element's top-level tags matter equally. For example, a renderer may mark the amenity=restaurant craft=caterer with a restaurant icon, but a search engine may label the same element as a caterer. Sometimes the meaning of a secondary attribute becomes ambiguous because of homonymous keys.

How to dual-tag

In the iD editor, you can dual-tag some kinds of features by choosing multiple feature types in succession. For example, you can draw an area, choose the Retail Building preset, click the Choose Feature Type button to return to the Feature Type menu, and choose the Cheese Store preset. The area will retain the building=retail tag because a combination with shop=cheese makes logical sense. Alternatively, you can use the Cheese Store preset's Building field to set the building=* key.

If two features have already been mapped and you want to combine them into a single dual-tagged feature, hold down Shift while selecting multiple features, then right-click and choose Merge to merge them into a single feature. If one of the features is a node and the other is an area, the node may be repurposed as one of the area's vertices, retaining its version history.

How to undo dual tagging

In the iD editor, right-click a dual-tagged area and choose Extract to extract a node containing the subset of tags related to a point of interest. This leaves the original area with all the other tags, as well as its version history.