Tag: relation in OSM

Data Structure- Relations

The basic data structure to map OSM are

  1. Nodes
  2. Ways
  3. Relations

To understand relations you should know about the first two elements. A Node is the x-y coordinate(basically a point) which is used to represent a point, icon on the map.

The table in the database which represent this nodes is planet_osm_nodes. This table defines the latitude, longitude of the point

Talking about the another element is “Ways” which is nothing but set of coordinates or a nodes to make a line, arc. In OSM it is used to represent rivers, boundary of a region etc.

The table in the database which represent these ways are planet_osm_ways. It displays unique id of a way, which nodes are participating to make a way and tags associated with the way.

Relations are an important data structure of OSM. Relations are basically combination of any of the two or all of the elements(Nodes, Ways, Relation). Relations are the conceptual database Model.

There are various types of relation like multipolygon, routes etc. To know more about relation types browse to http://wiki.openstreetmap.org/wiki/Types_of_relation

Invalid Multipolygons

  1. Unclosed Polygon like endpoint of way 2 and 3 are not joined.


  1. If the endpoint of a way share more than two ways. As shown in fig endpoints of way #2 is shared by way #3, #1, #4 .


Now, here I explain the table planet_osm_rels. There are columns id, rel_off, parts, members, tags.

  1. id– It assigns unique id to the osm relation. It can’t be null.
  2. rels_off– It tell number of members(nodes, ways, relation in total) participating to make a relation.
  3. parts– It tell which elements are participating by telling their unique id.
  4. members– It tell about the name of the element and associated role with it. Now here role describe the function of a member. Like, if type of relation is multipolygon than role of member(way) is inner or outer.

I think with this we have got a lot of overview of the data structures used in OSM.