Loading map data
To be able to create a map visualization, you need access to geographical data that connects to the data in your app. Geographical data comes in the form of either:
-
country and city names from your data
Information noteCountry and city names can be used as geographical data in maps only when data profiling is enabled. Data profiling is enabled by default.
- geopoint data (latitude, longitude) for a single location, such as a city
- area data (polygons of geopoints) to represent regions or countries
When you use Add data, Qlik Sense will try to recognize if your data contains cities or countries. If successful, a new field containing geographical information is created automatically.
If cities are recognized during data preparation, the new field contains geopoints, and if countries are recognized the new field contains area polygon data. This field is named <data field>_GeoInfo. For example, if your data contains a field named Office containing city names, a field with geopoints named Office_GeoInfo is created.
If a field is not recognized as geographical data, you can manually change the field type to geographical data.
See: Changing field types
Fields with geographical information do not display the geopoint or polygon data in the Associations preview panel or in the Tables view. Instead, the data is indicated generically as [GEO DATA]. This improves the speed with which the Associations and Tables views are displayed. The data is available, however, when you create visualizations in the Sheet view.
If your app data does not contain geographical entities that are recognized, or if you load data using the data load script, you need to load the geographical data from a separate file instead.
You can load point data from an Excel or KML file, or area data from a KML file. By default, all fields are selected in the data selection dialog, even if they do not contain any data. A KML file could contain, for example, area data but no point data. Although there is nothing wrong with loading empty fields, it can be inconvenient to have empty fields when you are working with the map visualization. Adding a dimension without any data to a map will not generate any visual output and could confuse a user. Therefore, you should clear the selections of all empty data fields in the data selection dialog, before you load the data.
Creating a map from data in a KML file
Normally, a KML file contains point data, area data, or both. In the following screenshot, from the data selection dialog, you can see that the selection of the field FloridaCounties.Point has been cleared because the field does not contain any data. By clearing the field you will not run the risk of creating map dimensions without any data.
When you click Insert script, the following script is generated:
If the selection of the empty field had not been cleared, the script would also have contained the following string:
When you run the script and add a map chart to the sheet, you can add either FloridaCounties.Area (area) or FloridaCounties.Name (area) as a dimension.
Although you will get the same visual result with either of the fields (a map with the counties), there will be a difference when you hover (tap on a touch device) over a county. If you select FloridaCounties.Name (area), the name of the county is shown as a tooltip, and if you select FloridaCounties.Area (area) the area data is shown. The name of the county is undoubtedly more interesting. In addition, loading the field FloridaCounties.Area is much slower than loading the field FloridaCounties.Name.
Optionally, you can also add a measure and use coloring by measure to reflect the difference in measure value between the different counties.
Creating a map from point data in an Excel file
You can create a map by using point data (coordinates) from an Excel file.
Point data formats
Point data can be read from Excel files. Two formats are supported:
-
The point data is stored in one column. Each point is specified as an array of x and y coordinates: [x, y]. With geospatial coordinates, this would correspond to [longitude, latitude].
When using this format, you need to tag the point data field with $geopoint;.
See: Loading point data from a single column with the data load script
-
The point data is stored in two columns, one for latitude and one for longitude.
- If you used Add data with data profiled enabled to load the table, the latitude and longitude fields are recognized, and a geopoint field is created automatically.
-
If you loaded the data using the data load script, you need to create a single field with point data in [x, y] format, using the function GeoMakePoint().
See: Loading point data from separate latitude and longitude columns with the data load script
In the following examples we assume that the files contain the same data about the location of a company's offices, but in two different formats.
Loading point data from a single column with the data load script
The Excel file has the following content for each office:
- Office
- Location
- Number of employees
The load script could look as follows:
The field Location contains the point data and it is necessary to tag the field with $geopoint so that it is recognized as a point data field. You also need to tag the field Office with $geoname so that it is recognized as the name of a geopoint. Add the following lines after the last string in the LOAD command:
The complete script then looks as follows:
Run the script and create a map visualization. Add the point dimension to your map.
Loading point data from separate latitude and longitude columns with the data load script
The Excel file has the following content for each office:
- Office
- Latitude
- Longitude
- Number of employees
The load script could look as follows:
Combine the data in the fields Latitude and Longitude to define a new field for the points.
Run the script and create a map visualization. Add the point dimension to your map.
You can choose to create the dimension Location in the script by adding the following string above the LOAD command:
LOAD *, GeoMakePoint(Latitude, Longitude) as Location;
The function GeoMakePoint() joins the longitude and latitude data together.
You also need to tag the field Office with $geoname so that it is recognized as the name of a geopoint. Add the following lines after the last string in the LOAD command:
The complete script then is as follows:
Run the script and create a map visualization. Add the point dimension to your map.
Number of points displayed
For performance reasons, the number of points that can be displayed is limited to 3333. However, a display value of over 1000 on a single map may affect readability. By making selections, you can reduce the amount of data to display.
Learn more
Did this page help you?
If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!