Print This Post

Coordinates in GML

Coordinates in GML can be a little confusing to the newbie. This is mostly because GML has more than one way of writing them. In many of the examples on this page coordinates are expressed using the gml:coordinates property tag.

For example:

1
2
3
  <gml:Point gml:id="p21" srsName="urn:ogc:def:crs:EPSG:6.6:4326">
    <gml:coordinates>45.67, 88.56</gml:coordinates>
  </gml:Point>

Note that when we express coordinates in this way, the individual coordinates like 88.56 are not visible in the XML – the whole text content of the <gml:coordinates> element is just one string. To make the coordinates visible in GML, GML 3. introduced the <gml:pos> element and then the <gml:posList> element. {GML already had the <gml:coord> element – however this should be treated as a defect and NEVER used}. Using the <gml:pos> element the above example is written:

1
2
3
  <gml:Point gml:id="p21" srsName="urn:ogc:def:crs:EPSG:6.6:4326">
    <gml:pos dimension="2">45.67 88.56</gml:pos>
  </gml:Point>

The posList element is used for list of coordinate tuples such as for linear geometries. A using the property would be written:

1
2
3
  <gml:LineString gml:id="p21" srsName="urn:ogc:def:crs:EPSG:6.6:4326">
    <gml:coordinates>45.67, 88.56 55.56,89.44</gml:coordinates>
  </gml:LineString>

Using the <gml:posList> element this would be written as:

1
2
3
  <gml:LineString gml:id="p21" srsName="urn:ogc:def:crs:EPSG:6.6:4326">
    <gml:posList dimension="2">45.67 88.56 55.56 89.44</gml:posList>
  </gml:LineString>

How do I know which to use?'''

In the future use only <gml:pos> or <gml:posList>.

Since many current GML data servers (WFS) and conversion tools may only support <gml:coordinates>, however, will change in the near future. If you are creating data – use <gml:pos> or <gml:posList>. If you are writing GML processing software it is a good idea to also support <gml:coordinates>. Support for <gml:coord> is not necessary.

To understand the use of the srsName attribute see the Wikipedia article on GML and Coordinate Systems.