What are KML and KMZ Files? Everything you need to know about Keyhole Markup Language.

If you spend time dealing with any kind of geospatial data or working with GIS applications, you’re bound to come across the .kml and .kmz file extensions eventually. But what is KML exactly?

In a nutshell, a KML file contains text written in the Keyhole Markup Language format. A KMZ file is a compressed (or Zipped) folder containing a KML file and any supporting files like images or icons that the KML references.

Okay, but what is Keyhole Markup Language and what does it do?

The main purpose of Keyhole Markup Language and the KML file format is to store, share, and display geographic data in a consistent way. Keyhole Markup Language and the KML file format were originally developed by Keyhole, Inc. for their eponymous Keyhole Earth Viewer program. If you’ve never heard of that application, you might know it better by it’s current name: Google Earth.

Google acquired Keyhole, Inc in 2004 and renamed the program which so many of us have used to cruise above the globe and zoom into places we may have only dreamed of visiting. Since then, it’s become an international standard managed by the Open Geospatial Consortium.

Keyhole Markup Language is specially designed to convey geospatial data in a consistent human-readable and machine-readable format. It not only houses the data so that it can be read at a later time, it’s also used to tell an application how and where to display the geospatial data on a 2D or 3D map of the Earth.

A KML file can describe a wide range of geospatial data including Place Marks (also known as Points or Places of Interest), Polygons (shapes), Images (projected onto the map), 3D Models, and more. It can even describe a viewport so that the program knows what angle and altitude the viewer should be observing the data from.

You can use KML to make maps displaying all kinds of different information at various locations and then send it to a friend who can open the file in a KML viewer and see the map exactly the way you intended it to be seen.

A screenshot of Google Earth Pro displaying the contents of a KML file that describes Google’s headquarters campus in California, USA.
Pictured: a KML file depicting Google’s headquarters as seen in Google Earth Pro.

What's the difference between KML and KMZ files?

Since KML is a text-based format, it doesn’t have a native way of embedding images. It can, however, reference file locations with images, and your KML viewer will attempt to fetch those files and draw them on the map. To be extra certain that the files will be in the right location when the KML viewer needs them, it’s helpful to bundle them into one folder or file and ship it all together. This is where KMZs come in. You can use compression software to place the .kml and all of its related images into a single .kmz file, and then that KMZ can be opened directly in your KML viewer, certain that it will find all of the files it needs.

As an added bonus, the compression that comes along with making a KMZ file makes them take up less space on your hard drive.

Great. Now how do I actually display a KML file?

Do you just need to view a KML or KMZ file that you got online, or do you need to edit it or create a new one to forward along? Are you going to be using it at your laptop or desktop in an office, or on a mobile device out in the field? These considerations make a big difference in what programs will work best for you.

Using a KML or KMZ file on a laptop or desktop in an office:

If you’re just trying to view the KML data on a map from your dekstop, the simplest option is, of course, Google Earth. Google Earth is a very simple yet powerful application for viewing and creating KML files and it’s completely free to use with both a web-based and downloadable desktop-based application. Google Earth Pro is the application shown in the screenshot above.

Using a KML or KMZ file on a mobile device and in the field:

We’re biased of course, but we think Touch GIS is hands down the best mobile KML viewer and editor around. You can download the app and view KML files on your mobile device for free. Opening KML and KMZ files is as simple as a couple of taps from the Project Manager screen, or from the Layers viewer.

If you need to edit and re-share the data, or view the KML in a remote area with no cell service, our professional subscriptions enable you to re-export the edited data in KML and many other file types. They also enable you to download map tiles for offline use, so if you need to visit a location displayed in the KML in a remote area, you can be certain that the map data will be available for you regardless of cell service in the area.

Touch GIS makes editing or drawing new KML files incredibly simple, requiring just a few taps or even free drawing with your finger or stylus to create lines and polygons. You can then add all kinds of different metadata to your new features, and can even attach photos. Once you’re done, sharing the KML or KMZ file requires just a few taps and an email or upload to a shared drive.

A screenshot of the Touch GIS Mobile application with the same Google Headquarters KML file rendered.
Here you can see the same Google Headquarters KML viewed in the Touch GIS mobile GIS app.

I've got a KML file but I need it in a different format. How do I convert it?

You may want to get the data into an easier-to-read format and so need to convert KML to CSV. Or maybe you’re using an ESRI product and want to convert KML to SHP. Yet other applications require you to convert KML to GeoJSON. Whatever your reason may be, there are various tools available to help convert your KML or KMZ to the format you need.

If you have a Touch GIS subscription, converting the file is as simple as importing it into a Touch GIS project and then exporting it in the format you want. We support all of the major file types and are always adding new ones.

Unless you’re a developer building the next great GIS application, that’s probably more than you’ll ever need to know about KML and KMZ files. If you have a question about KML files that we didn’t answer here, or any other question about geospatial information, feel free to reach out to blog@touchgis.app. We’re always happy to help!