Print This Post

GML and KML Syntax

I have noticed of late a number of requests on the Google Community site for 1) an XML Schema for KML and 2) Some attempt at converging KML with GML. To help this process along I thought would post some observations on the GML/KML overlap.

Purpose:

GML is intended to describe geographic objects. It uses application schemas written in XML Schema for this purpose.  It is NOT intended for graphical display. It leaves this to other grammars like SVG.

KML is one tool fits all. It defines geographic objects and their styling and their graphical representation. It uses schemas as part of the object description component, but uses its own schema language.

Syntax:

Since KML and GML serve different purposes they can only really be compared on their ability to describe geographic objects. 

KML provides a basic geometric objects including Point, LineString, Polygon.  Its geometry model is identical to GML v1.0 and 2.0.  Note that GML 3.0 is an extended version of the GML 2. geometry model.  Here is a comparison for a Polygon in KML and GML.

KML Polygon: (from the KML Reference http://www.keyhole.com/kml/kml_doc.html)

1
2
3
4
5
6
7
    <Polygon>
      <outerBoundaryIs>
        <LinearRing>
          <coordinates>…..</coordinates>
        </LinearRing>
      </outerBoundaryIs>
    </Polygon>

In GML this would look like:

1
2
3
4
5
6
7
    <gml:Polygon>
      <gml:outerBoundaryIs>
        <gml:LinearRing>
          <gml:coordinates>…..</gml:coordinates>
        </gml:LinearRing>
      </gml:outerBoundaryIs>
    </gml:Polygon>

Note that these are identical.  I could have surpressed the gml: in these examples as everything is in the same namespace. So far KML seems to be ignorant of namespaces.

If you look at all of KML, you will see that a fair number of tags are "borrowed" from GML.  The table of contents for the KML list of elements looks like this:

KML Elements

  • <address>
  • <altitudeMode>
  • <begin>
  • <color>                                      
  • <coordinates>                             (GML)
  • <description>                              (GML)
  • <Document>
  • <drawOrder>                             
  • <east>
  • <end>
  • <extrude>
  • <fill>                                          
  • <Folder>
  • <geomColor>                             
  • <GeometryCollection>                 (GML)
  • <geomScale>
  • <GroundOverlay>
  • <h>
  • <heading>
  • <href>
  • <Icon>                                       
  • <IconStyle>
  • <innerBoundaryIs>                       (GML)
  • <labelColor>
  • <latitude>
  • <LatLonBox>
  • <LinearRing>                               (GML)
  • <LineString>                                (GML)
  • <longitude>
  • <LookAt>
  • <name>
  • <NetworkLink>
  • <north>
  • <ObjArrayField>
  • <ObjField>
  • <open>
  • <outerBoundaryIs>                      (GML)
  • <outline>
  • <overlayXY>
  • <Pair>
  • <parent>
  • <Placemark>
  • <Point>                                       (GML)
  • <Polygon>                                  (GML)
  • <PolyStyle>
  • <range>
  • <refreshInterval>
  • <refreshVisibility>
  • <rotation>
  • <Schema>
  • <scale>
  • <ScreenOverlay>
  • <screenXY>
  • <SimpleArrayField>
  • <SimpleField>
  • <size>
  • <south>
  • <snippet>
  • <Style>
  • <StyleMap>
  • <styleUrl>
  • <tessellate>
  • <tilt>
  • <TimePeriod>                             (GML)
  • <TimeInstant>                             (GML)
  • <timePosition>                            (GML)
  • <type>
  • <href>
  • <Url>
  • <viewRefreshMode>
  • <viewRefreshTime>
  • <visibility>
  • <w>
  • <west>
  • <x>
  • <y>

I have annotated the elements which are copied from GML using (GML).  Styling from GML should thus be pretty easy.

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>