Keyhole Markup Language _KML_

Document Sample
Keyhole Markup Language _KML_ Powered By Docstoc
					     Keyhole Markup Language

Eric Bohn
Keith Krupp
What is KML? How Is KML Used?
Where Did KML Come From? Where Is It Heading?
KML is a XML-based language schema describing a geographic vocabulary used by geobrowser applications
    on two or three dimensional Earth maps.
KML was developed by Keyhole, Inc. along with the Earth Viewer application in 2001. Keyhole, Inc. was
    acquired by Google in 2004 and KML was converted for use for the Google Earth, Google Maps and Google
    Mobile applications.
The word Keyhole comes from an American military reconnaissance satellite program developed in the 1970's.
The Google Earth program both produces and consumes KML files.
KML uses the three-dimensional geographic reference system of longitude, latitude, and altitude to describe a
    basic point of view in space over or on the surface of the Earth; then adds more specific control over that
    view with heading, tilt, and roll factors.
KML also offers the ability to add text information, graphic overlays, 3-D polygons, paths, icons and add
    embedded files (images or auditory) to enhance the experience of the geobrowser applications.
In April 2008 the 2.2 KML language specification was accepted by the Open Geospatial Consortium as the
    official standard for geobrowser applications.
KML shares same structural grammar as the Geography Mark Up Language (GML) but provides more 3-
    dimensional graphical functionality.

Like all XML, KML must begin with the XML header information followed by the KML root element tags. The
    kml 2.2 namepace specification must be present in all KML files, and the gx namespace for Touring
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns=""
                        Basic Placemark

   <<?xml version="1.0" encoding="UTF-8"?>

   <kml xmlns="">
     <name>Gonda Building Rochester MN</name>
     <description>An example of a simple placemark on known terrain.</description>

A Placemark object contains the following elements:
· Name - the label for the Placemark
· Description - appears in the "balloon" attached to the Placemark
· Point- the position of the Placemark on the Earth's surface (longitude, latitude, and optional altitude)
· Auto-markup automatically converts text such as into active hyperlinks in the description.
· A CDATA tag or and HTML characters can be used to enhance the description (&lt;&gt)
                                 Import Features
A coordinate element consists of three floating point values (longitude, latitude, and altitude).

Latitude is degrees north or south of the Equator (0 degrees). Values range from -90 degrees to 90 degrees.

Longitude is the angular distance in degrees, relative to the Prime Meridian. Values west range from -180 to 0
   degrees and east o range from 0 to 180 degrees.

Altitude is the distance of the camera from the earth's surface in meters interpreted according to the
     altitudeMode element.

altitudeMode values include:
     relativeToGround – (default) meters above the ground or level of water body.
     clampToGround - exactly terrain or sea level height.
     absolute - meters above sea level

Heading is the direction (azimuth) in degrees from due North 0 to 360 degrees.

Tilt is the rotation in degrees around the X axis. A value of 0 indicates that the view is aimed straight down
     toward the earth (default), a value for 90 indicates that the view is aimed toward the horizon, values greater
     than 90 indicate that the view is pointed up into the sky. Values for are clamped at +180 degrees.

Roll is the rotation, in degrees around the Z axis. Values range from -180 to +180 degrees
                     LookAt Element
                                             <?xml version="1.0" encoding="UTF-8"?>
                                             <kml xmlns=""
                                               <name>Machu Picchu, Peru</name>

LookAt specifies the view of a virtual camera in terms of the point of interest
that is being viewed. Heading is the direction from due North in degrees.
                   Camera Element
                                            <?xml version="1.0" encoding="UTF-8"?>
                                            <kml xmlns="">
                                              <name>Golden Gate tour</name>

Camera specifies the view in terms of the viewer's position and orientation.

                             <?xml version="1.0" encoding="UTF-8"?>
                             <kml xmlns="">
                               <name>Ground Overlays</name>
                               <description>Example of a ground overlay</description>
                                <name>Picture over Previous Location</name>
                                <description>Overlay a picture of Rochester MN.</description>

The The <Icon> element contains the link to the .jpg file with the overlay image. The positioning of a ground overlay is controlled by
the <LatLonBox> tag. Bounding values are given for the north and south latitudes, and east and west longitudes. Image formats
supported are JPG, BMP, GIF, TIFF, TGA, and PNG.
                                                  Paths & Styles
                                                                                             <?xml version="1.0" encoding="UTF-8"?>
                                                                                             <kml xmlns="">
                                                                                                <name>Test Path</name>
                                                                                             <Style id="yellowLineGreenPoly">
                                                                                                 <name>Test Path</name>
                                                                                              -92.46604892696915,44.02163820523538,0 -
                                                                                               -92.46571114915615,44.02163823003409,0 -
                                                                                                     92.46548596234992,44.02163824608964,0 -
                                                                                                     92.46533583572284,44.02163825634765,0 -
                                                                                               -92.46499818064358,44.02161125789062,0 -
A path is created by a <LineString> element.
                                                                                                     92.46481099578385,44.02161124132853,0 -
                                                                                                     92.46462408744513,44.02161120429276,0 -
The <tessellate> tag breaks the line up into smaller chunks, and the <extrude> tag                   92.46443715040525,44.02161116735184,0
extends the line down to the ground.                                                               -92.46428760269356,44.02163815324332,0 -
                                                                                                     92.46410061298926,44.02163811674728,0 -
 When a Style and an ID is defined it can be used by Geometry, Placemarks, and                       92.46395102184133,44.02166510948038,0 -
Overlays, referred to as shared styles. The Style can be referenced multiple times,                  92.4637639797633,44.02166507438202,0
using the <styleUrl> element preceding the Style ID with a # sign. If the Style definition         -92.46353921861345,44.02166505125623,0 -
is in an external file, include the complete URL in the <styleUrl> element. A Document               92.46346424194114,44.0216650455531,0
is a container for features and styles. This element is required if your KML file uses
shared styles.                                                                                  </Placemark>
                                           Highlighted Icons
                                                                                         <?xml version="1.0" encoding="UTF-8"?>
                                                                                         <kml xmlns="">
                                                                                           <name>Highlighted Icon</name>
                                                                                           <description>Place your mouse over the icon to see it display the new
                                                                                           <Style id="highlightPlacemark">
                                                                                           <Style id="normalPlacemark">
                                                                                           <StyleMap id="exampleStyleMap">
Define a <Style> for the Placemark's normal icon including an <Icon> with an <href>         <Pair>
to the actual image to use.                                                                  <key>highlight</key>
Define a <Style> for the Placemark's highlight icon and assign an ID to it.                  <styleUrl>#highlightPlacemark</styleUrl>
Create the <StyleMap> element and assign an ID to it. The Placemark will refer to this
ID.                                                                                        <Placemark>
In the <StyleMap> element, specify "#normalicon" for the normal state.                      <name>Roll over this icon</name>
In the <StyleMap> element, specify "#highlightincon" for the highlight state.               <styleUrl>#exampleStyleMap</styleUrl>
In the Placemark, add a <styleUrl> element that refers to the stylmap.                      <Point>
                                                               <?xml version="1.0" encoding="UTF-8"?>
                                                               <kml xmlns="">
                                                                 <name>The Pentagon</name>
The polygon is made of simple inner and outer rings extruded          -77.05577677433152,38.87008686581446,100
down to the ground, then adding fill.                                 -77.05691162017543,38.87054446963351,100
                      Screen Overlays

                                               <?xml version="1.0" encoding="UTF-8"?>
                                               <kml xmlns="">
                                                 <name>Absolute Positioning: Top left</name>
                                                 <overlayXY x="0" y="1" xunits="fraction" yunits="fraction"/>
                                                 <screenXY x="0" y="1" xunits="fraction" yunits="fraction"/>
                                                 <rotationXY x="0" y="0" xunits="fraction" yunits="fraction"/>
                                                 <size x="0" y="0" xunits="fraction" yunits="fraction"/>

Screen overlays cannot be authored directly within Google Earth. Positioning is controlled by
mapping a point in the image specified by <overlayXY> to a point on the screen specified by
<screenXY>. In this case, the top-left corner of the image (0,1) has been made coincident with
the same point on the screen.
                                      KMZ File

A KMZ file consists of a main KML file and zero or more supporting files that are compressed and
   packaged with a zip application into an archive file with a .kmz suffix. The KMZ file can be stored,
   emailed and loaded from a web server. When the KMZ file is unzipped, the main .kml file and its
   supporting files are separated into their original formats and directory structure, with their
   original filenames and extensions. The kml file can then be run with Google Earth.
                      XML Schema For KML

To validate a KML XML document download the KML XML Schema document at:

Change the following code in the ogckml22.xsd from a hard coded file location to a web link URL:

 <!-- import atom:author and atom:link -->
 <import namespace=""

Add the xsi namespace and schemaLocation to the KML XML document you want to validate:
 <kml xmlns=""
  xsi:schemaLocation=" ogckml22.xsd">
                            Google Earth:
- KML was originally developed for Google Earth
     - Originally called Keyhole Earth Viewer
     - Originally created by Keyhole, Inc
           - Acquired by Google in 2004
- First program to view and graphically edit KML files.
- Maps the Earth by superimposing images obtained from satellite imagery,
  aerial photography, and GIS 3D globe.
- Easy navigation using mouse and control button.
- Most of Earth is available in 2D imagery only, but some places have 3D available.
     - 3D images of buildings and terrain are made available through digital elevation
         model imagery collected by NASA’s Shuttle Radar Topography Mission.
- Able to overlay images for comparing different types of information
     - Scale must be accurate, but image conforms to topography.
- Capability to build 3D models of cities
    - Irish town of Westport first to do so.
    - Helpful in promoting cities, and using for navigating city.

- Flight simulator (ctrl + alt + a)
           Google Earth 5.0, Touring
- Allows controlled flights through geospatial data
      - Specific flight druations between locations
      - Smooth flight past locations without stopping
      - Play sound files at predetermined times during the tour
-KML elements that define tours are containted within a set of extensions, using the
 gx prefix.
     - <kml xmlns=""
- Tours are constructed by placing specific elements, in order, into a KML file.
     - The KML file can contain any other legal KML elements together with the tour.
- Tours are made up of a series of tour primitives
     - FlyTos, Waits, TourControls, AnimatedUpdates, and SoundCues.
     - Tours move from location to location, each of which specified with a <gx:flyTo>
     - Updates to KML can take place during the tour
         Google Earth 5.0, Touring:
- Some of these primitives are played one after the other, waiting for one primitive to
  complete before beginning the next. Others run parallel to other primitives, so that
  multiple actions can occur simultaneously.
Comparable Products:

-NASA World Wind
-Earth 3D
-ESRI ArcGIS Explorer
-Virtual globe and world atlas you can use to learn more about Earth
-Mouse click on a place will bring up a wikipedia article
-Can measure distances between locations, and/or view weather
-Different “thematic” maps
    - Topographic view
    - Satellite view
    - Night view
    - Street map
-Free Open source software that promotes the use of free maps
-Can be used in C++/Qt 4.x applications
-Compatible with KML
              NASA World Wind
- Developed by NASA staff and open source community members
- Uses satellite imagery and elevation data to create a 3D view of Earth
- Can be used with other planets
- Compatible with KML/KMZ with KML/KMZ plug in

- Differences between Google Earth and NASA World Wind
    - Google Earth commercially produced, World Wind is not entirely.
    - Google Earth uses commercial satellite imagery which allows it to
       have more data than world wind.
    - Google Earth can’t be extended with user with user-authored add-
       ins or plug-ins like world wind can
    - Add-ons and plug-ins for Google Earth created in KML can now be
       used in world wind
    - World Wind covers more planets
    - World wind comes with more views out of the box
-With KML recognized as the standard for geographic visualization it will continue to
 evolve and grow as more and more geographic browsers continue to be developed,
And as the current geographic browsers grow it will be used more.
     - KML is the international standard.
-The OGC and Google have agreed to harmonize KML and GML further
     - GML is Geography Markup Language
        an XML based encoding standard for geographic information. The language
       allows Internet browsers the ability to view web-based mapping without
       additional components or viewers
     - This will allow for smoother interoperability between geographic browsers.

Shared By: