Use for consistent linking to OpenStreetMap, particularly for OSM relations that represent a route or place. The basic form of the link it produces is…

Numeric ID Wikipedia page name on OpenStreetMap

…with the element's numeric id shown first—linked to itself on OpenStreetMap—followed by the title of the wiki page it appears on (which can be customized, if necessary) and then a link to the OpenStreetMap article here on Wikipedia.

Discovering OSM element IDs

edit

All data present in OpenStreetMap consists of three types of core data elements:

  • Nodes: individual geographic positions, each with a unique and precise latitude and longitude
  • Ways: two or more nodes linked serially to form lines (which can be "open," with different nodes used for its beginning and end, or "closed," where the same node is used for its start- and endpoints, to define bounded areas or objects)
  • Relations: a semantic group of "member" nodes, ways and even other relations, each with assigned roles, representing logical (local) or geographic elements on the map

Each element has a numeric id (a signed 64-bit integer, specifically) associated with it (which is unique only within its element type, i.e. there are both a node and a way who have an id of 100 and they are completely unrelated to one another). Linking to a specific data element on OSM requires supplying its numeric id as part of the target URL, and they can be found either by using Nominatim or the standard OSM in-browser map interface (known as "iD").

Using Nominatim

edit

Nominatim is the official debugging interface for the search engine used on the OpenStreetMap website. There you can search for the map element you wish to link to by name and upon locating it, click the Details… link to display tabular data which will list its ID number.

Using iD

edit

iD is the name of the in-browser map interface available on the OSM home page. You can learn the numeric id of an element there by zooming in sufficiently that it fills the majority of your browser screen and then activating the 'Query features' mode by clicking the button on the right edge of the map, and then clicking on the element you wish to identify. The frame on the left will load a list of the data elements near where you clicked, and will highlight each one on the map as you hover over it with your cursor. Once you've identified the element you want, click it to load its details. The information shown at the top in boldface text will show the numeric ID you need enclosed in parentheses, according to the format below.

Element type: Name (Numeric ID)

Usage

edit

You must specify both an element's type and id as parameter values to the template. The type must be specified as the first parameter using the first letter of its name (n for a node, w for a way and r for a relation) and the numeric id must be the second. Lastly, if you wish to use something other than the title of the transcluding page as the link text (most often the common name of the element, if they differ), that text must be supplied as the third parameter. (Note: If your custom link text should for some reason include an equality symbol [=], then you must supply it as the value to the named positional parameter |3= instead for correct operation.)

edit

Links to OpenStreetMap relations are handled differently than the other two data element types, reflecting the fact that they represent more types of information than the other two. In a relation entity's numeric ID is supplied following the same format specified above ({{OSM|r|numeric id}}), it will be followed in the template's output by four more links—each consisting of a single letter—enclosed in parentheses: (xjah)

  • x: the raw XML data record of the element returned by the current OpenStreetMap API v0.6
  • j: the OSM JSON API version of the same data, for use with JSON-consumptive tooling
  • a: the OSM Relation Analyzer which offers a human-readable format of the relation data, with some basic derived information added where possible
  • h: the OSM History Browser, analogous to page histories here on Wikipedia, with a record of its membership and metadata tag changes over time, if any

Alternative output modes

edit

If a link created by this template to an OSM relation will be in a location where the additional links would not be helpful, their presence can be suppressed by passing a "false-y" Boolean value to the named |tools= parameter; those values are any case-insensitive form of:

  • false
  • off
  • no
  • n
  • 0

Going one step further, relations also have a "bare" output format that can be invoked by supplying the relation's numeric ID as the value to a single, named |relation=numeric ID parameter. This suppresses everything save the initial linked numeric value, relying on the editor to provide any necessary context in situ.

Examples

edit
Element
type
Wikitext Output
Node {{OSM|n|746952719}} 746952719 OSM/doc on OpenStreetMap
{{OSM|n|746952719|Chabua Air Force Station}} 746952719 Chabua Air Force Station on OpenStreetMap
Way {{OSM|w|28730330}} 28730330 OSM/doc on OpenStreetMap
{{OSM|w|28730330|Kemzekestraat}} 28730330 Kemzekestraat on OpenStreetMap
Relation {{OSM|r|9942914}} 9942914 (xjah) OSM/doc on OpenStreetMap
{{OSM|r|9942914|Noyo Bridge}} 9942914 (xjah) Noyo Bridge on OpenStreetMap
Alternative output formats
{{OSM|r|9942914|tools=off}} 9942914 OSM/doc on OpenStreetMap
{{OSM|relation=9942914}} 9942914

TemplateData

edit
This is the TemplateData for this template used by TemplateWizard, VisualEditor and other tools. See a monthly parameter usage report for Template:OSM in articles based on its TemplateData.

TemplateData for OSM

Display an external link to a specific data element on OpenStreetMap suitable for inline display

Template parameters

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
Element type1

Which of the three core OSM data element types you wish to link to

Suggested values
n w r
Linesuggested
Numeric ID2

The element's numeric ID on OpenStreetMap

Example
9942914
Numberrequired
Link text3

The text you wish to be linked to the element on OpenStreetMaps

Example
Noyo Bridge
Linerequired
Suppress tool linkstools

When assigned any "false-y" value, suppresses the four extra links to external tools shown by default for OSM relation entities

Example
off
Booleanoptional
OSM Relation IDrelation

The numeric id of the relation you wish to link to, producing a bare output format consisting of only the linked numeric ID; overrides all other parameters.

Example
9942914
Numberoptional

See also

edit