KML (Key Markup Language) and the compressed (zipped) version
KMZ is used in for example the program
Google Earth. The format is usable for spreading geographical information to persons without professional GIS programs. In this exercise we will export KMZ files from ArcMap, Read and create KMZ and KML files in Google Earth and also read and create KML files using Notepad.
Download the file areas.shp (and associated files) here.
Save and extract the data on your computer and open it in ArcMap.
Give the layer the color you want and export it as a KMZ file using the tool:
ArcToolbox > Conversion Tools > To KML > Layer To KML
(output file name).kmz
Start Google Earth and open the KMZ file you exported from ArcMap using:
File > Open…
You can try to click at the polygons and see the associated attribute data.
It is also possible to edit existing KML/KMZ files or create new ones using Google Earth.
Create for example polygons using:
Add > Polygon
And draw a polygon.
If the sidebar is hidden, click:
View > Sidebar
In the sidebar you can put your polygon and other things you add into folders and also change name and properties.
When you have created a folder containing some different things in different colors, right click at the folder and click:
Save Place As…
It is possible to choose if you want to save it as a KML or a KMZ. Save the folder you created using Google Earth both as a KML and a KMZ file.
The data in KML files following the structure of a code language called
XML (eXtensible Markup Language). Below is an example how to the region Scandinavia could be described using XML (not KML).
@@ <?xml version=“1.0” encoding=“UTF 8”?> <Region>
<Name>Scandinavia</Name> <Country> <Name>Sweden</Name> <Population>9500000</Population> </Country> <Country> <Name>Norway</Name> <Population>5000000</Population> </Country> <Country> <Name>Denmark</Name> <Population>5500000</Population> </Country>
The first part tells the computer that this is XML code and also define the method (in this case
UTF 8) of translating for example 00100100 (the binary code the data is build of):
The rest of the XML code is built on a hierarchical structure were parts start with <xx> and end with </xx>.
Open Notepad and open your files:
File > Open…
Text Documents to
All Files and open both the KML and the KMZ file you created in Google Earth.
The content of the KML file should exist of more symbols than the compressed KMZ file, but it is possible to read by a human.
We will now create a new KML file using Notepad. Start from a empty Notepad document and state that this is a XML dokument by writing:
@@ <?xml version=“1.0” encoding=“UTF 8”?> @@
The second part starts the XML code. Copy this row to your document:
The third part is the actual information that in this case give coordinates for the point
<Placemark> <name>Subway</name> <Point> <coordinates>18.0547,59.3652,0</coordinates> </Point> </Placemark>
The last part end the KML code.
@@ </kml> @@
Save the file with the file extension
.kml instead of
.txt and open the file in Google Earth.
Create also a file with the same placemark but with one additional placemark named T Centralen and with the coordinates: 18.059, 59.331
Also save this file with the file extension
.kml and open the file in Google Earth.
(Save all the files on a place you can find tomorrow.)
More about how KML files are built can be found here: https://developers.google.com/kml/documentation/
And more about XML can be found here: http://www.w3schools.com/xml/