Qlik Community

Qlik Sense Documents

Qlik Sense documentation and resources.

Read about the latest Qlik Community enhancements on the Community News blog!

Create a KML polygon shape file manually and use it in Qlik Sense

Contributor III
Contributor III

Create a KML polygon shape file manually and use it in Qlik Sense

I spent some time working through this process for a project and thought I'd document my approach. These instructions were created using Qlik Sense Desktop v 2.0.1. but should be compatible with all versions of Qlik Sense as KML data is a commonly used source.

For the following example I have used the best of the few websites that are freely available at the time of writing. There are others but some don’t provide a readable form of KML or miss certain tags in the KML that are needed. The site I use for this example is http://www.birdtheme.org/useful/v3tool.html

I’d be delighted to hear if anyone has a better option. However, this site has served me well in creating a few examples and if you follow the steps you should get a decent result with minimal effort (unless you’re plotting a very complex set of polygons of course).

I have attached all files that I used in creating this demo, as well as the final Qlik Sense .qvf file (no extensions needed). You can follow the steps and create it yourself or review the files.

What is a KML Polygon shape file

KML (keyhole markup language) allows us to create map overlays using geo coordinates (longitude, latitude) for set of many points which create a shape and a contained area. These files are used when showing countries on a world map or states on a map of the US but any shapes can be created using geo coordinates. These shapes can then be color coded, showing heat maps etc, and are fully selectable in Qlik Sense. This example will walk you through this process.

Create the KML Polygon file

1. Open Tool for Google Maps v3 (version 3) and navigate to the area I wish to create a KML File for… I’ve chosen Dubai Mall just for an example.


2. To create some polygon shapes on this map, ensure that polygon is selected from the first dropdown menu (see screenshot above).

3. Click on [Next Shape] to activate the map for a polygon capture.

4. As you click around the boundary of the shape a polygon will appear shaded in purple.


5. Once you have completed your shape (you can always [Delete Last Point] if you have clicked in error) click on [KML input] as we need to define a <name> for our polygon shape, in my example I will call this ‘Building 42’. Then click [Save].


6. Click on [Next Shape] to create the next shape following the same steps. For example I have created 7 shapes with names ‘Building 40’ through to ‘Building 46’.


7. When you have completed the last shape and saved the name change. Click on [Show KML] and copy the text that appears in the box.

8. Open a notepad (or similar text editor) window, paste this code and save the file as a .xml file (please ensure that you do not save it as a .txt file by selecting all files as the save as type when saving). In my example I have saved the file as Dubai Mall.kml

Create your Qlik Sense application

1. Create a new application.

2. Drag the [Sales Details (kml test).xlsx] file into your Qlik Sense application and load in the Sales Data dataset (worksheet). Note the [Store Name] field holds the same data as we have entered against the Polygon shapes. Load this data.

3. Drag the [Dubai Mall.kml] file into your Qlik Sense application. The second field [Dubai Mall.Point] is blank so uncheck this field


4. Click on Profile to use the smart data load to compare the two data sources.

5. It will show us that a field in each dataset contains 100% the same value set. [Store Name] and [Dubai Mall.Name]. Click on this recommendation and rename both fields to [Store Name]..


6. Load and finish

7. The data model viewer will now show a model with a join as below.


8. The autogenerated script in the data load editor will look as below.


Use the KML file in a map object

1. Create a new sheet in your Qlik Sense application.

2. Click into Edit mode, and drag in a Map Chart object

3. Drag the field [Store Name] into the map object on your screen and it should add your shapes immediately.


4. Drag in some other objects and when you filter on Store Name, or select on the KML shape you will see the application apply the filter.

5. My first example below highlights how the colors can show the relationship between the shape and the Store Name. I’ll accept it is a little colorful.


Extend this example with conditional color formatting

1. Create the following color effect on the KML map object


2. create a measure in the master objects using the formula:

num((sum([Sales Amt TW])/sum([Sales Amt LW]))-1,'#,##0.0%')

Setting the num() format mask in the measure makes life easier when using the measure in multiple objects.

3. Drag this measure into your map and click on [Add “Sales Growth %”]

4. On the right hand side properties, navigate to Appearance > Colors and legend. Uncheck the auto color selector and select 'by expression' in the dropdown

5. Use the following formula to set a green and red color based on RGB values:

if([Sales Growth %]>0,rgb(120,255,120), if([Sales Growth %]<0,rgb(255,120,120), rgb(220,220,220)))

6. Now you have a dashboard which indicates how the stores are performing within the KML polygon shapes allowing you to see areas/ stored that are performing and those that are not.

I hope this guide is useful, please leave some feedback if you have any ideas for improvement.

Important note:

In using the Google maps API to generate these shapefiles you should be aware that this may be against the terms of use that we have all agreed to with Google by simply using Google Maps. There are alternative mapping options such as Open Street Maps etc (which Qlik Sense makes use of) but I have yet to find a KML generator such as this using this a mapping source..

Contributor II
Contributor II

This is very helpful as I got a custom map built for a particular large building.

How do you go about creating areas within a building?  For example, I am working with a large terminal, so my KML is of the entire terminal. How do I plot out set locations within the terminal map (ie. identifying rooms or checkpoints)? I was using the Google Maps tool and selecting HOLE, but I can't seem to get it to do what I would like.

Contributor III
Contributor III

Hi Thomas,

The KML Layer is pretty simplistic and therefore you would need to build each area as a polygon in and of itself. If there is a hole in the shape you need to create then I suspect you'd need to make the polygon shape have a hole in the middle, i.e. create it as a distinct shape where two sides are adjacent to each other but the coordinates still map out a single shape.

However, I have just tried to do this as an example using the website used in the instructions and I can see this is not possible as it will not let you select a point within the already shaded area, and therefore the shape is hard to make with a hole. As such a quick workaround would be to create multiple adjacent shapes that give you the required output where each shape is given the same label that joins to your dataset.

I will investigate this further as it does seem to be a limitation of this resource...


Not applicable

Hello Richard, thank you very much for your contribution. I`ve just successfully tried it.

I`ve also try with my own data of sales in Argentina, and it doesn`t work

"An error ocurred", The Hypercube results are too large"

The KML has 23 states with their corresponding geolocation poligon.

Do you know if it is possible to reduce the kml file? or what do you suggest?

I found the kml file in GeoServer: Layer Preview

Thank you very much for your help

Contributor III
Contributor III

Hi Ignacio,

Check the instructions in one of my other posts (link below) to use open source software to reduce the point density of the KML file you have.


It's reasonably simple if you follow the steps although not the most intuitive software.



Sent from my iPhone

Not applicable

Thank you. This was really very helpful to me.

However, instead of using that tool, I have found that google gives you the ability to draw your own polygons/maps, and you can even save them and get back to them later on.

just to to http://mymaps.google.com/ and start creating your maps. You can save the, have copies of them, and even export them to KML or KMZ files.

The good thing about it, is that it helps you drawing the adjacent polygons by automatically moving the mouse pointer on to the closest point when you move your mouse near points of the same or adjacent polygons. I don't know if I have made myself clear. Anyway, try it

Contributor III
Contributor III

Thanks for the feedback Maysarah!

I looked at a number of sites before settling on this one as they all have their limitations and this one met my own needs at the time. I will check out the Google option (they all use Google APIs so it makes sense that google has an option too) next time I go through the process and I'll be interested to see how flexible it is... Luckily you tend to only have to do the shapefile once providing you get it right!


Not applicable

Hi, I don't want to be negative but please beware of the Google Maps user terms when creating shapes from their base map. The terms doesn't not allow derivative work.

Google Maps/Earth Additional Terms of Service – Google

"2. Restrictions on Use. Unless you have received prior written authorization from Google (or, as applicable, from the provider of particular Content), you must not: (a) copy, translate, modify, or make derivative works of the Content or any part thereof;"

Another way could be to use OpenStreetMap instead, just remember to give credit and release the work under the same terms. Legal FAQ - OpenStreetMap Wiki


Patric Nordström, Idevio

Contributor III
Contributor III

Hi Patric,

Thanks for the useful input as most of us never make it to reading the small print of these 'agreements'... It's a very interesting point and an area that I'm sure you've been much more involved in than most of us. I will look into the capability of doing this with OpenStreetMap but a quick search was a bit fruitless for anything that is relatively easy to use rather than coding a KML file yourself with all the GPS points. It will give me something to look at when I next get some quiet time..

Thanks again.


Not applicable

Exporting polygons from OSM is a bit tricky, I found the Overpass API convenient for small extractions, there is a nice site for that: http://overpass-turbo.eu/s/dcp

After exporting, you probably need to edit the shapes a bit, editing attributes, adding or removing shapes etc. Then QGIS (www.qis.org) can be an ok tool to use, with QGIS it is also possible to draw shapes and export.


Patric Nordström Idevio

Not applicable

Hi Richard,

Nice post! We've been trying out the mapping functionality with some success, but would like to know if there is anyway of using the kml shape file as a background for a point map? This is so we can create bubbles on top of the kml shape, like you can on top of the slippy map at the moment.



Version history
Revision #:
1 of 1
Last update:
‎2015-08-29 02:20 PM
Updated by: