Technical Overview: GML

GML (Geography Markup Language) is based on XML and was developed by the Open Geospatial Consortium (OGC) to express geographic features.

GML is a geographic modeling language that can also be used for Internet transactions. It encodes geographic content by describing application objects and their properties. This contrasts with KML (Keyhole Markup Language), which describes object visualization and annotation. GML does not usually have presentation information.

GML was developed between 1998 and 2003, has been adopted as a specification by the OGC. It is also an ISO Standard (ISO 19136). GML uses an XML schema, but it was originally based on RDF (Resource Description Framework). This history has resulted in the use of child elements for properties and remote propery references.

GML uses application-specific schemas instead of one static schema. In other words, it functions as a kind of toolkit to build a schema specific for the application at hand. This compares with KML which has only one schema (although a software package may only support specific features). This results in a rich toolkit that can be tailored to the application at hand, but it does mean that one application’s GML can probably not be read by a second application. A good enalogy would be XML itself. An XML file produced by one high level application will probably not be readable by a second high level application unless support for the file’s schema is explicitly provided.

A GML file will typically refer to multiple namespaces. For example, MPSuperShape produces GML files that refer to the GML namespace and its own mpss namespace. Here is an example:

<?xml version="1.0" encoding="utf-8"?>
<!--GML / MapPoint Shape File, created by MPSuperShape, http://www.mpsupershape.com-->
<mpss:Mappoint 
    xmlns:gml="http://www.opengis.net/gml" 
    xmlns:mpss="http://www.mpsupershape.com/mpss mpss.xsd">
 <mpss:Shape gml:id="MPSS_1">
  <mpss:lineColor>255</mpss:lineColor>
  <mpss:fillColor>-1</mpss:fillColor>
  <gml:extentOf>
   <gml:Polygon>
    <gml:outerBoundaryIs>
     <gml:LinearRing>
      <gml:coordinates>39.2536340653896,-76.9408676214516 38.9559591561556,-76.4966512285173 38.6956850532442,-76.9231356214732 38.7565893027931,-77.2658491786569 38.7682131584734,-77.2658848855644 38.8263081293553,-77.2772478125989 38.9832367189229,-77.2740040160716 39.0735032781959,-77.1208223048598 39.282743409276,-77.0346763730049 </gml:coordinates>
     </gml:LinearRing>
    </gml:outerBoundaryIs>
   </gml:Polygon>
  </gml:extentOf>
 </mpss:Shape>
</mpss:Mappoint>

In contrast, here is an extract from a UK Ordnance Survey Mastermap GML file:

<?xml version='1.0' encoding='UTF-8'?>
<osgb:FeatureCollection
    xmlns:osgb='http://www.ordnancesurvey.co.uk/xml/namespaces/osgb'
    xmlns:gml='http://www.opengis.net/gml'
    xmlns:xlink='http://www.w3.org/1999/xlink'
    xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
    xsi:schemaLocation='http://www.ordnancesurvey.co.uk/xml/namespaces/osgb http://www.ordnancesurvey.co.uk/xml/schema/v4/OSDNFFeatures.xsd'
    fid='GDS-20818-88'>
 <gml:description>Ordnance Survey, (c) Crown Copyright. All rights reserved, 2006-01-27</gml:description>
 <gml:boundedBy>
  <gml:null>unknown</gml:null>
 </gml:boundedBy>
 <osgb:queryTime>2006-01-27T14:06:41</osgb:queryTime>
 <osgb:queryExtent>
  <osgb:Rectangle srsName='osgb:BNG'>
   <gml:coordinates>595000.000,215000.000 600000.000,220000.000</gml:coordinates>
  </osgb:Rectangle>
 </osgb:queryExtent>
 <osgb:boundaryMember>
  <osgb:BoundaryLine fid='osgb1000001602272985'>
   <osgb:featureCode>10136</osgb:featureCode>
   <osgb:version>9</osgb:version>
   <osgb:versionDate>2005-02-17</osgb:versionDate>
   <osgb:theme>Administrative Boundaries</osgb:theme>
   <osgb:accuracyOfPosition>2.5m</osgb:accuracyOfPosition>
   <osgb:changeHistory>
    <osgb:changeDate>1993-11-05</osgb:changeDate>
    <osgb:reasonForChange>Modified</osgb:reasonForChange>
   </osgb:changeHistory>
   <osgb:changeHistory>
    <osgb:changeDate>1993-11-19</osgb:changeDate>
    <osgb:reasonForChange>Modified</osgb:reasonForChange>
   </osgb:changeHistory>
   <osgb:changeHistory>
    <osgb:changeDate>2001-11-26</osgb:changeDate>
    <osgb:reasonForChange>Attributes</osgb:reasonForChange>
   </osgb:changeHistory>
   <osgb:changeHistory>
    <osgb:changeDate>2003-07-26</osgb:changeDate>
    <osgb:reasonForChange>Position</osgb:reasonForChange>
   </osgb:changeHistory>
   <osgb:changeHistory>
    <osgb:changeDate>2003-07-26</osgb:changeDate>
    <osgb:reasonForChange>Attributes</osgb:reasonForChange>
   </osgb:changeHistory>
   <osgb:changeHistory>
    <osgb:changeDate>2003-12-17</osgb:changeDate>
    <osgb:reasonForChange>Attributes</osgb:reasonForChange>
   </osgb:changeHistory>
   <osgb:changeHistory>
    <osgb:changeDate>2005-01-24</osgb:changeDate>
    <osgb:reasonForChange>Modified</osgb:reasonForChange>
   </osgb:changeHistory>
   <osgb:descriptiveGroup>Political Or Administrative</osgb:descriptiveGroup>
   <osgb:descriptiveTerm>Parish</osgb:descriptiveTerm>
   <osgb:physicalLevel>50</osgb:physicalLevel>
   <osgb:physicalPresence>Boundary</osgb:physicalPresence>
   <osgb:polyline broken='true'>
    <gml:MultiLineString srsName='osgb:BNG'>
     <gml:lineStringMember>
      <gml:LineString>
       <gml:coordinates>596002.530,216076.000 596005.100,216073.200 596000.000,216067.550 </gml:coordinates>
      </gml:LineString>
     </gml:lineStringMember>
     <gml:lineStringMember>
      <gml:LineString>
       <gml:coordinates>596000.000,216070.300 595992.100,216058.200 595986.900,216053.600 595980.400,216047.200 595970.300,216037.300 595965.800,216031.800 595960.800,216027.000 595955.700,216021.600 595950.700,216017.100 595942.000,216007.400 595935.150,216000.000 </gml:coordinates>
      </gml:LineString>
     </gml:lineStringMember>
     <gml:lineStringMember>
      <gml:LineString>
       <gml:coordinates>595935.150,216000.000 595932.150,215997.000 595925.980,215989.810 595920.900,215984.810 595911.440,215974.510 595902.280,215965.520 595900.880,215964.110 595898.400,215961.920 595895.600,215960.010 595895.100,215959.720 595892.010,215958.220 595887.930,215956.410 595881.050,215952.810 595879.460,215952.300 595876.970,215951.200 595874.470,215949.900 595873.770,215949.400 595866.600,215944.700 </gml:coordinates>
      </gml:LineString>
     </gml:lineStringMember>
    </gml:MultiLineString>
   </osgb:polyline>
  </osgb:BoundaryLine>
 </osgb:boundaryMember>
 <osgb:boundedBy>
  <gml:Box srsName="osgb:BNG">
   <gml:coordinates>594180.260,213410.160 600729.820,220421.210 </gml:coordinates>
  </gml:Box>
 </osgb:boundedBy>
</osgb:FeatureCollection>

The Mastermap standard uses the GML namespace with the osgb standard. This allows for the very rich set of map descriptions required for the OS’s map data – in contrast to the very simple map description required by MPSupershape to represent MapPoint annotation. Notice also, that the two files use two very different coordinate systems. Mastermap also supports features that change and are updated over time.

GML’s primitives provide support for features, geometry, coordinate reference systems, time, dynamic features, map coverage, units of measure, and presentation styling rules. These can be restricted by profiles. For example, the Point Profile supports point geometric data. This is extended by the Simple Features Profile which adds support for 2d and aggregate geometries.

The application-specific nature of GML combined with its richness is both a strength and a weakness. It can result in a very rich and expressive language, as demonstrated by the OS’s Mastermap standard. The richness can also result in very large files. Mastermap is typically delivered as compressed files, and even a small area such as an English county can take up multiple DVDs. This is very rich data, but clearly it could not be delivered over the Internet. However, GML intended for Internet delivery could be much reduced in detail and depth. The second problem is the application-specific schema. Whilst KML or SHP files are portable between different applications, this is rarely the case with GML.

Leave a Reply