Qlik Sense Geospatial Functions With Example
Interactive Online Courses: Elevate Skills & Succeed Enroll Now!
1. Objective
In our last Qlik Sense tutorial, we discussed Qlik Sense File Functions. Today, we will see QliK Sense Geospatial Functions. The geospatial functions evaluate the geospatial data using in the map visualizations. The geometries supported in Qlik Sense and these functions are point geometry, line string geometry, polygon geometry, and multipolygon geometry.
So, let’s start Qlik Sense Geospatial Functions tutorial.
You must read – QliK Sense Day Numbering Functions
2. What is QliK Sense Geospatial Functions?
The QliK Sense Geospatial Functions have two categories, aggregation and non-aggregation functions. The aggregation geospatial functions take in a set of geospatial data as input and return a single return which is the aggregation of all. For instance, you can provide the coordinates of multiple areas and the function would return a single boundary aggregating all the multiple boundaries.
Whereas, non-aggregation functions take in single data points as input and return a single result value. Thus, no aggregation involves here. Below, are the functions under each category.
3. Aggregation QliK Sense Geospatial Functions
i. GeoAggrGeometry
This function takes in a number of area data points as input and returns the aggregated area i.e. a larger area as a result. You can use multiple sub-regions or suburb area boundaries as input values and this function will return a cumulative boundary or a bigger region adding up the boundaries of the sub-regions or suburbs. This function is of great significance when we want to analyze a business trait in a territory comprising of multiple data points, as this function will apply aggregation on all the individual data points and return a territory.
Syntax for QliK Sense Geospatial Functions –
GeoAggrGeometry(field_name)
Where, field_name is the name of the field which contains individual data points or values which are taken as input values for aggregation.
For example, in the sample script given below, the area points for individual areas are loaded in the field world.Areas which is aggregated by the GeoAggrGeometry(world.Areas) from the table ‘worldareas’ which is a KML file. This will return the aggregated area in the newly created field called AggrArea. Also, it is important to use the Group By clause in a data load statement.
[MapSource]: LOAD [world.Name], [world.Points], [world.Areas] FROM [lib://Downloads/worldareas.kml] (kml, Table is [Worldareas.shp/Features]); Map: LOAD world.Name, GeoAggrGeometry(world.Areas) as [AggrArea] resident MapSource Group By world.Name;
ii. GeoBoundingBox
This function takes in a number of data points of an area and returns the value of four coordinates which makes the smallest bounding box or the coordinates making the smallest rectangle.
Have a look at Qlik Sense Integer Functions
Syntax for QliK Sense Geospatial Functions:
GetBoundingBox(field_name)
Where, field_name is the name of the field which contains all the geospatial data values corresponding to an area. The values are a set of points representing the latitude, longitude, or i.e. the coordinates marking area points.
iii. GeoCountVertex
This function returns the number of vertices present in a polygon geometry.
Syntax for QliK Sense Geospatial Functions:
GetCountVertex(field_name)
Where, field_name is the name of the field which contains all the geospatial data values corresponding to an area. The values are a set of points representing the latitude, longitude, or i.e. the coordinates marking area points.
iv. GeoInvProjectGeometry
This function returns the inverse of a projection of a geometry originally aggregating the given set of data points.
Syntax for QliK Sense Geospatial Functions:
GeoInvProjectGeometry(type, field_name)
Where, type is the type of projection or geometry in which the existing geometry of the map will be transformed. There are two types of projections, ‘unit’ which is set by default and returns a 1:1 projection, and the other is ‘mercator’ which returns the standard Mercator projection of the aggregated area.
Recommended Reading – QliK Sense Financial Functions
field_name is the name of the field which contains all the geospatial data values corresponding to an area. The values are a set of points representing the latitude, longitude, or i.e. the coordinates marking area points.
For example, in the piece of code given below, is given a loaded statement which contains the area coordinates in the field ‘PolygonArea’. The geometry contained in this field will transform into the inverse of Mercator projection. The transformed geometry is then stored in the field, ‘InvProjectGeometry’.
GeoInvProjectGeometry(‘mercator’,PolygonArea)as InvProjectGeometry
v. GeoProjectGeometry
This function applies a projection on a geometry which was aggregating from the given set of data points.
Syntax for QliK Sense Geospatial Functions:
GeoProjectGeometry(type, field_name)
Where, type is the type of projection or geometry in which the existing geometry of the map will be transformed. There are two types of projections, ‘unit’ which is set by default and returns a 1:1 projection, and the other is ‘mercator’ which returns the standard Mercator projection of the aggregated area.
field_name is the name of the field which contains all the geospatial data values corresponding to an area. The values are a set of points representing the latitude, longitude, or i.e. the coordinates marking area points.
For example, in the piece of code given below, is given a load statement which contains the area coordinates in the field ‘PolygonArea’. This function will apply the Mercator projection on the geometry of the aggregated data points given in the field PolygonArea. The applied projection is then stored in the field, ‘ProjectGeometry’.
GeoInvProjectGeometry(‘mercator’,PolygonArea)as ProjectGeometry
Know more about Qlik Sense Table Functions
vi. GeoReduceGeometry
This function returns the reduced area of a larger area created from aggregating a number of data points. The individual area boundaries still shows on the map even after the reduction of the area as a whole.
Syntax for QliK Sense Geospatial Functions:
GeoReduceGeometry(field_name[, value])
Where, field_name is the name of the field which contains all the geospatial data values corresponding to an area. The values are a set of points representing the latitude, longitude, or i.e. the coordinates marking area points.
Value sets the amount of reduction you want to apply on the complete area or geometry. You can use any value ranging from 0 to 1 where, 0 corresponds to the no reduction, and 1 corresponds to maximum reduction. Any decimal value between these two will cause reduction corresponding to it.
For example, in the sample script given below, the area points for individual areas are loaded in the field world.Areas which is reduced by 0.5 using the function GeoReduceGeometry(world.Areas). The field exists in the table ‘worldareas’ which is a KML file. This will return the aggregated area in the newly created field called ReducedArea. Also, it is important to use the Group By clause in a data load statement.
[MapSource]: LOAD [world.Name], [world.Points], [world.Areas] FROM [lib://Downloads/worldareas.kml] (kml, Table is [Worldareas.shp/Features]); Map: LOAD world.Name, GeoReduceGeometry(world.Areas,0.5)as [ReducedArea] resident MapSource Group By world.Name;
4. Non-aggregation Qlik Sense Geospatial Functions
i. GeoGetBoundingBox
This function calculates the smallest possible geospatial bounding box enclosing all the coordinates of an area or geometry. This function returns a string having four values, which are right, left, top, and bottom coordinates of the bounding box.
You must read QliK Sense Date and Time Functions
Syntax for QliK Sense Geospatial Functions:
GeoGetBoundingBox(field_name)
Where, field_name is the name of the field which contains all the geospatial data values corresponding to an area. The values are a set of points representing the latitude, longitude, or i.e. the coordinates marking area points.
We use this function in chart and script expressions.
ii. GeoGetPolygonCenter
This function returns a string which contains the longitude and latitude value of the center of a polygon or of any geometric area/shape enclosed in boundaries.
Syntax for QliK Sense Geospatial Functions:
GeoGetPolygonCenter(field_name)
Where, field_name is the name of the field which contains all the geospatial data values corresponding to an area. The values are a set of points representing the latitude, longitude, or i.e. the coordinates marking area points.
iii. GeoMakePoint
This function returns a point on the map by the latitude and longitude values provided in the function itself. The points returns with the coordinates corresponding to the longitude and latitude, in that order.
Syntax for QliK Sense Geospatial Functions:
GeoMakePoint(lat_field_name, lon_field_name)
Where, lat_field_name is the field or expression which provides the latitude values.
lon_field_name is the field or expression which provides the longitude values.
iv. GeoProject
This function applies a projection to a geometry or area.
Let’s discuss the Qlik Sense Mathematical functions
Syntax for QliK Sense Geospatial Functions:
GeoProject(type, field_name)
Where, type is the type of projection or geometry in which the existing geometry of the map will be transformed. There are two types of projections, ‘unit’ which is set by default and returns a 1:1 projection, and the other is ‘mercator’ which returns the standard Mercator projection of the aggregated area.
field_name is the name of the field which contains all the geospatial data values corresponding to an area. The values are a set of points representing the latitude, longitude, or i.e. the coordinates marking area points.
For example, in the piece of code given below, is given a load statement which contains the area coordinates in the field ‘Area’. This function will apply the Mercator projection on the geometry of the field Area. The applied projection is then stored in the field, ‘GetProject’.
GeoProject('mercator',Area) as GetProject
So, this was all in Qlik Sense Geospatial Functions. Hope you like our explanation.
5. Conclusion
Hence, the geospatial functions are a special lot of functions which we apply to the geospatial data values and can use in the map visualizations. These functions make working with geospatial values easy and convenient.
See also –
If you are Happy with DataFlair, do not forget to make us happy with your positive feedback on Google