Saturday, February 28, 2009

Understanding KML

Understanding KML, which is the XML compliant format for sharing data with Google Earth requires reading and adhering to the KML Reference documentation at http://code.google.com

KML is essentially an XML compliant format for designating all of the relevant information that you wish to show in the your favorite display application. All data dependent applications require some form of contract, and with Google Earth, this contract is called KML. Within a document, you will find the element, which contains style sheet information as well as the point, circle or polygon shape objects, their icons, names, descriptions, latitude, longitude and elevation attributes.

According to Google, You can create KML files with the Google Earth user interface, or you can use an XML or simple text editor to enter "raw" KML from scratch. KML files and their related images (if any) can be compressed using the ZIP format into KMZ archives. To share your KML and KMZ files, you can e-mail them, host them locally for sharing within a private internet, or host them publicly on a web server. Just as web browsers display HTML files, Earth browsers such as Google Earth display KML files. Once you've properly configured your server and shared the URL (address) of your KML files, anyone who's installed Google Earth can view the KML files hosted on your public web server.

Many applications display KML, including Google Earth, Google Maps, Google Maps for mobile, NASA WorldWind, ESRI ArcGIS Explorer, Adobe PhotoShop, AutoCAD, and Yahoo! Pipes. This makes it a suitable standard for creating interactive business intelligence products.

A basic KML document might look like the following:

<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Placemark>
<name>My office</name>
<description>This is the location of my office.</description>
<Point>
<coordinates>-122.0821604290386,37.42041505714916</coordinates>
</Point>
</Placemark>
</kml>


What this is describing is a simple placemark control having the minimum properties to be displayed within Google Earth. We see we have a single Placemark element, and within that placemark, we have a name [required], a description [required], and a [Point], also required. A point in Google Earth contains either both the latitude and latitude of a point, assuming the elevation sticks to the surface of the earth, or you can choose to include a third parameter within the coordinates tag to specify altitude.

Essentially, all kml documents we create will be relevant to your data and can be augmented with additional attributes to further enhance the experience.

I will dissect more complicated examples next time.

No comments:

Post a Comment