What is KML?
Keyhole Markup Language (KML) is a programming language that is formatted in Extensible Markup Language (XML) for geospatial data visualization. KML was first created in 2001 by a company called Keyhole that was later acquired by Google in 2004. In 2008 KML became one of the international standards for geospatial data visualization under the Open Geospatial Consortium. To display KML files requires a geo-browser applications such as Google Earth, Microsoft Virtual Earth, ESRI ArcGIS Explorer, and so forth. In addition a KML file can also be displayed in Google Map.
A KML file for an application is quite easy to make and very dynamic. KML is able to display various geospatial data format, such as vector, raster including non geospatial data format like 3D and even animation. Because of the rich abilities, the KML widely used for various applications, for example:
- Ordinary users can display the location a trip points, marking business places, bicycling route and others, as well as adding information such as photo, video and link.
- Scientists can use KML to visualize changes in the weather or the movement of clouds, virus spreading, earthquakes pattern and so on.
- Government can be able to show potential locations for investors, location of program activities, identify potential areas for development, etc.
KML File Structure
A KML file begins with a XML open tag, with include the XLM version that is used and the type of data encryption. Then followed with KML tag which include KML version. After the initiation, its followed by content syntax. At the end of the section, like other XML formatting language must be closed by a pair tag, in this case the KML file must be closed with </ kml>.
A KML file structure can be seen in a piece of code below.
<? Xml version = "1.0" encoding = "UTF-8"?>
<Kml xmlns = "http://www.opengis.net/kml/2.2">
The contents of the document ...............
</ Kml>
KML is case sensitive, meaning that differences in uppercase and lowercase letters must be considered.
KML Data Support
KML language has ability to display geospatial data and non geospatial data format. For geospatial data itself, it can display vector data in basic geometry such as points, lines and polygons. For raster it can view standard image data in JPEG or PNG. For non geospatial data format it support 3D objects, video and photo. With those data support, a user can have various options to visualize the data as needed. In figure one, we can see an image overlay on google earth. The image is a PNG data type.
KML Vs. KMZ
Might be sometimes we get a file with a KMZ extension. What is it exactly? KMZ file is a compressed KML file. KMZ file is used to reduce the file size and also useful to store data in one file. For example, we create a KML file for a city tour that contain pictures of tourist attractions. The KML file that contains point location of tourist attractions and photos can be placed in a folder, with a KML file in the same folder named doc.kml. So that the point of the tourist attractions when clicked will trigger a pop up window showing related photos that have been stored in the same Foder. Finally, the folder is compressed into a zip format, and the zip extension is changed to kml.
How to Create a KML File
To create a KML file can be tricky, depends on the needs. In general there are two ways to create a KML file, programming or using a tool.
1. Programming
In this way we have to write the KML script manually. Of course its quite difficult, because we have to know the KML language script or syntax. But programming gives us a freedom to be more creative. For example, we can create a complex KML application like animation, image/photo overlay, automation (refresh and expiration) and flexibility for object properties setting.
2. Using a Tool
The second method using a data conversion tool. For example using data conversion tool in ArcGIS software. There are also many online tools available, just search it with your favorite search engine and you will find it right away.
Where To Learn KML
There are many resources out there to learn about geospatial data visualization with KML. One which I prefer is KML tutorial from google developer website.