Qlik Sense GeoOperations
Qlik Sense GeoOperations enables geographic calculations and functions such as calculating routes or travel areas. It also enables loading geographic data from a wide variety of data sources. Qlik Sense GeoOperations enables you to solve geographic problems with your data, such as:
- Determining how many customers are living within a 15-minute drive from a store location
- Linking GPS positions to venues, regions, or road networks
- Building custom sales areas from a list of municipalities
- Finding the closest hospital for a list of patients
GeoOperations functions are available in scripting for both the data load script and in visualization expressions. GeoOperations functions can each load data implicitly. GeoOperations functions also can be used to transform geographic data or make calculations.
Features
-
Available in the script language in Qlik Sense SaaS.
- Extracts spatial relations so that they can be handled by Qlik.
- Load time lookups of locations (as an alternative to the presentation time lookups in the map chart).
- Aggregation of points in clusters or bins.
- Specify locations as:
- Point, line, or area geometries in the same format as QlikGeoAnalytics and Qlik Sense
- Latitude and longitude fields
- Named points or areas
- Load geographic data from a range of input formats.
- Use operations on data already loaded in Qlik.
How GeoOperations works
Qlik Sense GeoOperations works by sending script and optionally a table to the GeoOperations extension in the load script. The server side extension then returns the data. GeoOperations makes an Advanced Analytics Integration object called "GeoOperations" available in the script language that provides the function ScriptEval for sending the script and the table to the extension. For example, the following is the load script for applying the TravelAreas operation to the previously loaded table MyPoints and specify parameters for the size/cost of the travel area:
Load * Extension GeoOperations.ScriptEval('TravelAreas(costValue="10", costUnit="Minutes")', MyPoints);
The script is sent as the first parameter to ScriptEval and the table as the second.
The GeoOperations are functions that operate on datasets. The datasets either come from data loaded in Qlik Sense or from external sources such as geographic files or the location service. The data sent out from the script is available as a dataset named INTABLE. If you want to specify additional parameters on that data, you need to declare it after the function call as a DATASOURCE. For example:
Load * Extension GeoOperations.ScriptEval('TravelAreas(costValue="10", costUnit="Minutes")
DATASOURCE myPoints INTABLE pointField="Point"', MyPoints);
Other data sources always need to be declared and parameters such as URLs need to be specified. In each operation you can specify the data sources to use. By default, operations pick up the available datasets as described for each operation in Operation.
Where to use GeoOperations
All operations can be used in the data load script. Certain operations can be used in expressions in chart scripts for maps as well to enable dynamic calculations. Each time the selection changes, the operation is run. Data does not go into the data model when GeoOperations are used in charts, preventing further analysis of that data.
Selecting and renaming GeoOperations fields
GeoOperations functions return fields. By default, all fields are returned and included. You can precede GeoOperations functions with a SELECT statement to select and optionally rename specific fields in which you are interested. For example, this script uses SELECT to load only two of the postal code fields from the location service:
Load * Extension GeoOperations.ScriptEval('
SELECT Name as PostalCode, LocationArea FROM
Load() DATASOURCE PostalCodes LOCATIONSERVICE type="PostalCode", country="se"');
Using a SELECT statement in the GeoOperations script can be more efficient than specifying fields in Qlik LOAD statement as the data is not loaded into Qlik Sense if it is not selected in the GeoOperations script.
SELECT can be used to avoid calculating some fields by choosing not to return them in the results. For example, the relative overlap fields returned by Intersects can be excluded.
If you are using the same operation multiple times in your load script, use a SELECT statement to rename the fields.
Limitations
The following limitations apply to the maximum size of datasets:
- Max number of rows: 50,000
- Max dataset size in memory: 150 MB
- Max rows with routing: 400
- Max rows with name lookups: 20,000
Some operations support streaming data from Qlik Engine. Data streamed from Qlik Engine can be larger, but the size limit for routing still applies.
Script syntax
The script that can be sent to GeoOperations has the following syntax:
1. Operation
The simplest form of the script performs an operation.
Syntax:
Operation(paramName="paramValue", ...)
Example:
Cluster(distance="100000")
For more information, see the list of Operations and their parameters.
2. Dataset
The second step is to load a dataset for your chosen operation(s) to be applied to.
Syntax:
Operation(paramName="paramValue", ...)
DATASOURCE name TYPE paramName="paramvalue", ...
Example:
Within()
DATASOURCE states LOCATIONSERVICE type="STATE", country="US"
For more information, see the list of Datasets and their parameters.
3. Putting it together
This is how the completed script would look in the Data load editor:
[MyPointsInStates]:
Load * Extension GeoOperations.ScriptEval(’
Within()
DATASOURCE states LOCATIONSERVICE type=”STATE”, country=”US”
’, MyTable);
In this example, MyTable can be any other loaded table containing points, lines, named areas, or other geographic data.
4. Filter fields
The following additions allow the results of the operation to be further filtered.
[MyPointsInStates]:
Load * Extension GeoOperations.ScriptEval(’
SELECT Name, states.Name as State FROM
Within()
DATASOURCE states LOCATIONSERVICE type=”STATE”, country=”US”
’, MyTable{Name, Point});
Parameter names and field names are case sensitive but operations, parameter options (like meters, minutes, car, and so on) or keywords such as SELECT and FROM are not.