Migrating from GeoAnalytics Connector to Qlik Sense GeoOperations
Qlik Sense GeoOperations in Qlik Cloud Services and Qlik Sense Enterprise on Kubernetes provides similar features and operations as the GeoAnalytics Connector does with in Qlik Sense Enterprise on Windows. They also support many of the same data formats. They have the following differences:
- GeoOperations is an Advanced Analytics Integration (AAI), which is more suitable for sending out and processing data than a connector.
- GeoOperations is only accessible from the script language, there is no wizard for GeoOperations.
- Script syntax is different for Advanced Analytics Integrations than for connectors.
- GeoOperations can also be used in chart expressions.
- GeoOperations returns a single table. Compared to what the Connector returns, the tables are joined in GeoOperations.
- In GeoOperations some fields and parameters has been renamed to be more consistent.
The following outlines how to convert the script produced by the GeoAnalytics Connector Wizard to GeoOperations:
- In Data load editor, in the GeoAnalytics Connector script code, copy everything after SQL up to the second SELECT or ";", whichever comes first.
- Replace all ' in the GeoAnalytics Connector script with ".
-
Add the selected field names from the secondary SELECT statement in the GeoAnalytics Connector script to the first SELECT statement in the GeoOperations script. Omit any fields that are already there. Add the source table name to the field names, separating them with a period. For example, table.field.
This will create a single joined table instead of several tables.
-
Review the reference documentation for the operation and dataset and adjust any parameter or field names where needed.
-
Add the following to the start of the GeoOperations script:
Load * Extension GeoOperations.ScriptEval('
-
Add the following to the end of the GeoOperations script:
');
If using a loaded table with the GeoAnalytics Connector, send it as the second parameter to GeoOperations.ScriptEval instead.
As GeoOperations returns a joined table, only field values that have a corresponding value in the primary table are returned from the secondary tables. For example, if you want to find the closest airports in Germany for some points, only data about airports that are closest to the points are returned. If you want all airports in Germany, they need to be loaded separately with a LOAD operation.
If loading from an SQL database with the connector, the data should instead be loaded with one of the database connectors like the ODBC connector. Make sure to load the geometries as WKT (apply a function usually called st_asText() in the SQL query). Then convert the WKT field by sending the table to GeoOperations. It will then return a field with the geometries in Qlik Sense format.
Example script conversion
This script conversion example will use the following GeoAnalytics Connector script:
/* Generated by GeoAnalytics for operation Cluster ---------------------- */
[ClusterAssociations]:
SQL SELECT [LocationDbId], [Clusters_ClusterID] FROM Cluster(distance='10000', points='Points')
DATASOURCE Points LOCATIONSERVICE geometry='POINT', type='XIATA', country='de', serviceName='default'
SELECT [Clusters_ClusterID], [Clusters_ClusterCenter] FROM Clusters;
[Clusters]:
SQL LOAD * FROM Clusters;
tag field [LocationDbId] with '$primarykey';
tag field [Clusters_ClusterID] with '$primarykey';
tag field [Clusters_ClusterCenter] with '$geopoint';
tag field [Clusters_ClusterID] with '$geoname';
tag field [Clusters_ClusterCenter] with '$relates_Clusters_ClusterID';
tag field [Clusters_ClusterID] with '$relates_Clusters_ClusterCenter';
/* End GeoAnalytics operation Cluster ----------------------------------- */
Do the following:
-
Take the script between SQL and the second SELECT statement.
SELECT [LocationDbId], [Clusters_ClusterID] FROM Cluster(distance='10000', points='Points')
DATASOURCE Points LOCATIONSERVICE geometry='POINT', type='XIATA', country='de', serviceName='default'
-
Replace quotes:
SELECT [LocationDbId], [Clusters_ClusterID] FROM Cluster(distance="10000", points="Points")
DATASOURCE Points LOCATIONSERVICE geometry="POINT", type="XIATA", country="de", serviceName="default"
-
Add fields from secondary tables:
SELECT [LocationDbId], [Clusters_ClusterID], [Clusters.Clusters_ClusterCenter] FROM Cluster(distance="10000", points="Points")
DATASOURCE Points LOCATIONSERVICE geometry="POINT", type="XIATA", country="de", serviceName="default"
-
Adjust parameter and field names:
SELECT [LocationDbId], [ClusterID], [Clusters.ClusterPoint] as [Clusters_ClusterCenter] FROM Cluster(distance="10000", points="Points")
DATASOURCE Points LOCATIONSERVICE geometry="POINT", type="XIATA", country="de", serviceName="default"
-
Enclose in boilerplate code:
Load * Extension GeoOperations.ScriptEval('
SELECT [LocationDbId], [ClusterID], [Clusters.ClusterPoint] as [Clusters_ClusterCenter] FROM Cluster(distance="10000", points="Points")
DATASOURCE Points LOCATIONSERVICE geometry="POINT", type="XIATA", country="de", serviceName="default"
');
This script code now can be used with Qlik Sense GeoOperations.