File Structure

KML, like other XML-based formats, can be visualized as a tree structure, where each node in the tree corresponds to an XML element. The root element of a kml file is the <kml> xml element. The <kml> element can contain a <NetworkLinkControl> element, and one other element that inherits from the kml <Feature> type; for practical purposes, the KML writer creates a <Document> element to contain all sub-elements. The KML reader makes no assumptions regarding the contents of the <kml> element.

The <Document> element is a container element that can, in turn contain the following sub-elements:

  • <Folder>: Another container element that can contains the same sub-elements as a <Document>.
  • <Placemark>: Displays a feature with either Vector or 3D geometry
  • <GroundOverlay>: Displays (overlays) a feature with Raster geometry
  • <ScreenOverlay>: Draws a image overlay that is fixed to a certain location in the viewspace.
  • <PhotoOverlay>: Geographically locates a photograph on the earth
  • <NetworkLink>: References a KML file or KMZ archive on a local or remote network.
  • <gx:Tour>: Provides a guided tour of the dataset for the user.

In addition, the <Document> element can contain the following elements that provide important display and meta-information

  • <Style>: Defines an addressable style group that can be referenced by Stylemaps and Placemarks.
  • <StyleMap>: Defines a mapping between two different styles.
  • <Schema>: Defines a schema for embedding custom data within KML

<gx:Tour> elements can contain an arbitrary number of <TourPrimative> elements. These include:

  • <gx:AnimatedUpdate>: Uses an <Update> element to create temporary changes to the dataset.
  • <gx:FlyTo>: Changes the user’s view to focus on a certain area.
  • <gx:SoundCue>: Plays a sound file.
  • <gx:TourControl>: Changes tour’s play mode.
  • <gx:Wait>: Adds an arbitrary time delay.

With the exception of <Schema> elements, FME maps a fixed schema to each of the aforementioned KML elements; each of the element names map to a well-defined FME feature type. I.e. a feature with a Placemark feature type maps to a <Placemark> kml element.