September 07, 2005

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)

<Polygon>
   <outerBoundaryIs>
      <LinearRing>
         <coordinates>.....<coordinates>
      </LinearRing>
   <outerBoundaryIs>
<Polygon>

In GML this would look like:

<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:

o                    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.

Posted by RLake at 02:15:33 | Permanent Link | Comments (8) |
Comments
1 - Given the link between KML and GML 1, could we go so far as to say KML is "standards-based"? (Comment this)

Written by: Jeff Harrison at 2005/09/11 - 17:23:19
2 - Don't thnk we could say that KML is open standards based even though it copies some elements from GML since they are NOT in the GML namespace. If the used GML elements (e.g. Point, Polygon etc.) were declared in the GML namespace then I would say YES it is open standards based. (Comment this)

Written by: Ron Lake at 2005/09/12 - 17:59:53
3 - It would be "standards-based" if Google simply "extended" GML 2.0. As mentioned previously, all Google would have to do is IMPORT the GML 2.0 schemas (feature.xsd and geometry.xsd) into their KML schema and then submit the extension to the OGC (www.opengeospatial.org) as an official "standard" extension. Perhaps their biggest fear is rooted in the overly complex and arguably broken GML 3.0+. At any rate, I think that it's wise for them to wait for an XML schema release so that developers don't lock themselves into the restrictions that schema allow you to express, such as: multiplicities, data types, parent/children/sibling relationships. Hopefully they lock down KML soon so that XML schemas can become available, namespace referencible (if that's a word), and more "standard". (Comment this)

Written by: Travis Rennemann at 2005/09/12 - 19:09:41
4 - "arguably broken GML 3.0+"...?...do tell. (Comment this)

Written by: Martin Kyle at 2005/09/14 - 17:20:28
5 - To make KML standards based it would have to import the GML schemas and make use of the GML elements. It would be easy to create a KML for example as a GML feature. On the otherhand, one can readily argue that KML is not primarily concerned with geographic object description. It might be more appropriate to look at KML as a map visualization language. (Comment this)

Written by: Ron Lake at 2005/09/16 - 15:39:30
6 - Perhaps GMLSF (GML for Simple Features) can serve as a foundation if Google has concerns about GML 3.
 (Comment this)

Written by: Jeff Harrison at 2005/09/21 - 09:46:31
7 - hello sir,

My self kazumi vakharia. I am studying M.E.(comp)..
I am doing research on GML. So kindly request to you sir that what is feature of GML and in which editor i should write.which is the best Xml editor...

thank you,sir


kazumi vakharia (Comment this)

Written by: kazumi at 2006/07/13 - 04:11:06
8 - is it possible to read "GML" files on google earth software? (Comment this)

Written by: Anonymous at 2008/07/15 - 23:51:00
Write a comment