XML - Managing Data Exchange/Google earth

KML Introduction
(most content here is directly quoted from the KML wikipedia article)

KML (Keyhole Markup Language) is an XML-based Markup language for managing the display of three-dimensional geospatial data in the programs Google Earth, Google Maps, Google Mobile, ArcGIS Explorer and World Wind. (The word Keyhole is an earlier name for the software that became Google Earth; the software was produced in turn by Keyhole, Inc, which was acquired by Google in 2004. The term "Keyhole" actually honors the KH-11|KH reconnaissance satellites, the original eye-in-the-sky military reconnaissance system now some 30 years old.)

The KML file specifies a set of features (placemarks, images, polygons, 3D models, textual descriptions, etc.) for display in Google Earth, Maps and Mobile. Each place always has a longitude and a latitude. Other data can make the view more specific, such as tilt, heading, altitude, which together define a "camera view". KML shares some of the same structural grammar as Geography Markup Language|GML. Some KML information cannot be viewed in Google Maps or Mobile.

KML files are very often distributed as KMZ files, which are Data compression|zipped KML files with a .kmz extension. When a KMZ file is unzipped, a single "doc.kml" is found along with any overlay and icon images referenced in the KML.

Example KML document:

   New York City New York City  -74.006393,40.714172,0    

The MIME type associated to KML is application/vnd.google-earth.kml+xml.

The MIME type associated to KMZ is application/vnd.google-earth.kmz.

Basic KML Document Types
For an XML document to recognize KML specific tags you must declare the KML namespace (listed below).



You will see this declaration in all the example files listed.

In order to see use the examples provided in this chapter you will need to copy and paste the text into any text editor. Next you will save the file as a .kml. This can be done by choosing "save as" and naming the file with a .kml extension (You might have to surround the name in quotes ie "test.kml").

Placemarks
Placemarks simply make a clickable pinpoint inside Google Earth at an exact location based on coordinates. This can be useful for marking a point of interest or a beginning and ending destination to a trip.

The example KML document in the introduction uses the Placemark tag. If you want to move the placemark to a different location all you would change are the coordinates.

Paths
Paths are a series of connected coordinates that can be edited with line styles for a more bold appearance inside Google Earth. The height and color can be adjusted for a more exaggerated appearance and better clarity.

The following example is a path from Atlanta, Georgia to Nashville, Tennessee. The code may look a bit complicated but it is mostly just styling/formatting tags with the 4 actual coordinates at near the end. So if you wanted to use the same style wall but just make a different path, all you would do is change the coordinates.

 

 Paths Path from Atlanta to Nashville

  7f00ffff 4        7f00ff00  

<Placemark> Atlanta to Nashville Wall structured path <styleUrl>#yellowLineGreenPoly</styleUrl> <LineString> 1        1         <altitudeMode>absolute</altitudeMode> -84.40204442007513,33.75488573910702,83269 		-84.37837132006098,33.82567285375923,83269 		-84.79700041857893,35.30711817667424,83269 		-86.79210094043326,36.15389499208452,83269      </LineString>

</Placemark> </Document>

Overlays
Overlays are graphics that can be placed over an area in Google Earth marked by coordinates. These graphics can show how an area looked at a different point in time or during a special event (like a volcanic eruption).

This overlay example comes from Google's KML samples webpage and shows what Mt. Etna looked like during an actual eruption.

<?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://earth.google.com/kml/2.1"> <Folder> Ground Overlays Examples of ground overlays <GroundOverlay> Large-scale overlay on terrain Overlay shows Mount Etna erupting on July 13th, 2001. <Icon> http://code.google.com/apis/kml/documentation/etna.jpg </Icon> <LatLonBox> 37.91904192681665        37.46543388598137         15.35832653742206         14.60128369746704         -0.1556640799496235       </LatLonBox> </GroundOverlay> </Folder>

You can see from the code that it takes the image etna.jpg and places it over the coordinates listed.

Polygons
Polygons are a neat feature of Google Earth that allow 3-D shapes to be molded anywhere in Google Earth. These shapes can be useful for making neat presentations or just showing the world a structure actually looks.

This example is a polygon of Turner Field (The Atlanta Braves' home stadium) in Georgia. There is no styling on the polygon to keep the code simple.

<?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://earth.google.com/kml/2.1">

<Placemark> Turner Field <Polygon> 1      <altitudeMode>relativeToGround</altitudeMode> <outerBoundaryIs> <LinearRing> -84.39024224888713,33.73459764262901,28 		-84.38961532726215,33.73451197628319,28 		-84.38830478530726,33.7350571795205,28 		-84.38811742696677,33.73579651137399,28 		-84.38856034410841,33.73618350237595,28 		-84.38930790023139,33.73647497375488,28 		-84.38997872537549,33.73655338302832,28 		-84.39051294303495,33.73605785090994,28 		-84.39056804786146,33.73528763589146,28 		-84.39024224888713,33.73459764262901,28

</LinearRing> </outerBoundaryIs> </Polygon> </Placemark>

As you can see from the code, the polygon's 3-D shape is made up from the latitude and longitude coordinates with the height being determined by the 3rd column value inside the coordinates tag (28 in this case).

Google Earth
Google Earth is the name of Google's free software that is responsible for handling these KML documents. It is a virtual world created by a collage of satellite images where a user can manipulate the Earth in any way to see its landscapes, oceans, and cities.

You can find more information and download the software here.

Basic Interface Navigation
The user interface is fairly straight forward and is extremely easy for computer illiterate users to just jump right in and start exploring. You can completely ignore the toolbars and buttons if you want and just click and grab on the Earth to shake, spin, or roll it as you please. To zoom in, simply right-click and pull down or up depending on the speed which you prefer to "fall" toward the surface.

If you would like help finding a location you can type in the location (in the form of City, State) in the "Fly to.." search box. Google Earth will then spin around and zoom in to the location entered. If you want to take a virtual vacation, Google has some preset locations saved in the window below "Fly to..." labeled "Sightseeing." Simply click on one of these locations and be taken to the location where pictures, articles, and comments can be all be viewed.

Points of Interest
Points of interest that Google has already marked for users are marked with different color dots and icons. These can be clicked on for a variety of information ranging from a simple comment, to a panoramic photograph of that exact location. Advanced users, interested in the code make-up of such a feature, can right click on any of Google's marks and choose "Copy." This will copy all the code for that feature where you can just paste it into a text document to see all of the tags and references.

Other notes

 * Point of Interest
 * Geography Markup Language

Wikipedia in other languages

 * كيه إم إل (Arabian)
 * Keyhole Markup Language (German)
 * KML (Spanish)
 * Keyhole Markup Language (Italian)
 * Keyhole Markup Language (Hungarian)
 * Keyhole Markup Language (Dutch)
 * Keyhole Markup Language (Polish)
 * KML (Russian)


 * /Exercises/