Understanding KML
KML, or Keyhole Markup Language, is an XML-based format used to express geographic annotation and visualisation. It's designed for use with two-dimensional maps and three-dimensional Earth browsers.
As an open standard maintained by the Open Geospatial Consortium (OGC), KML is widely supported across various platforms, making it ideal for sharing and visualising geospatial data.
Creating KML files for Qlik Sense
KML Structure Basics
A KML file consists of features primarily represented by placemarks (points), polygons (areas), or lines. These features are organised hierarchically, allowing for complex geographic information representation.
Creating the KML file
- Open Google Earth and use the search bar to find your desired location. ("Willen Lake, Milton Keynes" for example.)
- Click the "+ New" button in the top left corner to create a new project. For simplicity, create a "Local KML file" rather than importing from Google Drive. This will appear in the "Local KML files" section on the left panel.
- To create an area polygon, select the polygon tool (icon with connected dots) from the toolbar. Begin clicking points on the map to outline your desired area. The image shows a yellow dotted line being drawn around a lake.
- After completing your polygon, a dialog box will appear with details about the area. Save the polygon to your project and rename it (e.g., "Lake 1"). The map view now shows the outlined lakes.
- To add a label point, select the placemark (pin) icon from the toolbar. Click on the map where you want to place the point. Name this point to match its corresponding polygon (e.g., "Lake 1") for easier linking in other software.
Repeat steps 3-5 for additional areas or points as needed. The left panel will show your saved items under your project name.
Remember, you can turn off "3D Buildings" in the layers option if they obstruct your view while drawing. This process allows you to create both area polygons and point markers for further use in other applications.
Exporting the KML file
This step is nice and straightforward, simply hover over the project title, select the 3 dots that appear to show the settings and select ‘Export as KML file’.
Importing KML into Qlik
Bringing your KML data into QlikSense is a straightforward process:
- Add your KML file to QlikSense:
Simply drag and drop your KML file into your datafiles connection in Qlik SaaS. QlikSense is designed to recognise and read KML files directly through its data editor.
- Preview and analyse the data:
Once imported, QlikSense's data selection wizard will automatically preview the data for you. It will prefix the KML fields with the filename for easy identification. In our example, you'll notice we have 4 rows, each containing a point value and an area value for each 'name'. This structure reflects how we named the point and area values identically in Google Earth during creation.
Tip: If you hadn't completed and closed the area polygon in Google Earth, it would have been saved as a line, which can also be loaded into QlikSense.
- Load the data using an appropriate script
To properly import the KML data, you'll need to use a specific loading script. Here's an example of the script used to load our KML data:
Willen:
LOAD
WillenLakeDemo.Name as Name,
WillenLakeDemo.Point as Point,
WillenLakeDemo.Area as Area
FROM [lib://DataFiles/WillenLakeDemo.kml]
(kml, Table is [Willen Lake]);
This script loads the Name, Point, and Area fields from our KML file, renaming them as needed.
- Examine the imported data
After loading, you can view the data in a table in QlikSense. You'll notice that the Point field consists of a single longitude and latitude pair, while the Area field is made up of a series of longitude and latitude pairs. This structure allows QlikSense to properly render both point markers and area polygons on your maps.
Using the KML in Qlik
Qlik's intuitive interface makes working with KML data straightforward:
Recognising geographical data:
Qlik automatically identifies geographical data, indicated by a globe symbol next to field names in the field selector.
Creating basic maps:
Simply drag the geographical field onto a sheet. Qlik will automatically create a map chart with an area layer using the area data.
Adding point data:
To incorporate point data:
- Disable 'chart suggestions' in the properties panel
- Create a new 'point layer'
- Use 'Name' as the dimension and set 'Point' as the location field
The result is a map displaying both area and point data, demonstrating the versatility of KML elements created in Google Earth.
Advanced visualisation example:
To showcase more complex applications, we've created a mock mining data visualisation:
- The lake is divided into grid sections, each with a point reference
- Polygon grids in the area layer illustrate locations and enable area selections
- Points in a density layer create heatmaps showing material concentration
Summary
This blog has explored the integration of KML with QlikSense, showing you how to enhance your geospatial data analysis. Some of the key takeaways are:
- Versatile applications: From sales territories to urban planning, KML and QlikSense work across various fields.
- Data transformation: Convert complex geographical information into clear, actionable insights.
- Pattern recognition: Identify trends and opportunities hidden in your spatial data.
- Informed decision-making: Leverage geographical insights for better strategic planning.
- User-friendly tools: Easily create dynamic, interactive maps with your data.
Ready to see how KML and QlikSense can transform your data analysis? Get in touch to explore the possibilities for your organisation: