Skip to main content
Announcements
Jan 15, Trends 2025! Get expert guidance to thrive post-AI with After AI: REGISTER NOW
ArturoMuñoz
Employee
Employee

Today I'll be posting on behalf of Yang Yang who recently came up with this interesting article around the geospatial functions available in Qlik Sense, I'm sure you'll enjoy it.

Arturo

Qlik Sense is Gorgeous and Genius. So far, you probably have seen the intelligent visualizations that are out-of-the-box in Qlik Sense, including maps. What about advanced geospatial functions such as merging geometries or the converting spatial projections? Will those features be added in Qlik Sense product? I recently bumped into a few geospatial functions that are not yet well known. Here are the findings from my experimenting of those functions. The QVF and supporting data are also available for download at the bottom of the article.

Two categories of functions

There are two categories of these geospatial functions: aggregation and non-aggregation.

Aggregation functions will take the input of a set of geometries (points or areas) and output with one geometry. For example, you can merge multiple areas together and draw a single boundary for the aggregation on the map. On the other hand, non-aggregation function will only take the input of one geometry and then output one geometry. For instance, you provide the boundary geometry of one area to a function called GeoGetPolygonCenter, it will return the point geometry (longitude and latitude) for the center of that area.

There are two types of parameters that may required by the geospatial functions:

- Geometry, can be any of the following:

  • a point (latitude, longitude)
  • an area

- Projection, With Mercator projection you can represent maps in square format, correcting for the distortion created by stretching. This can be any of the following:

  • 'unit' (default) - projection is 1:1
  • 'mercator'

Aggregation functions

There are five aggregation functions available in the current release of Qlik Sense (1.0.1).

GeoAggrGeometry

This function can be used to aggregate a number of areas into a larger area, for example aggregating a number of sub-regions to a region.

GeoAggrGeometry(geometry).

A typical use case of this function is: A company has geospatial boundary data for each postcode areas in Sydney and the sales revenue from each area. A sales person has his or her sales territory that covers a number of postcode areas. The sales territory will be adjusted from time to time and there's no geospatial data for the boundary of this changing territory. How can the company present the total of sales by region on a color filled map?

OriginalAreas.jpgAggregatedAreas.jpg

With GeoAggrGeometry(), we can calculate the aggregation of multiple suburb level geometries and generated the merged territory geometry in the data model. If the sales territory changes, the new merged boundary can be reflected on map after the reload.

GeoReduceGeometry

This function can be used in scripts to aggregate a geometry into an area.

GeoReduceGeometry(geometry)

This function is similar to GeoAggrGeometry(). The only difference is, though the areas are aggregated, area level boundary lines are still kept on the map display.

AggrVsReduce2.jpg

GeoBoundingBox

This function can be used in scripts to aggregate a geometry into an area and calculate the smallest GeoBoundingBox that contain all coordinates.

A GeoBoundingBox is represented as a list of four values: left, right, top, bottom.

As explained above, this function will firstly aggregate a set of geometries together, then it will produce four coordinates for the smallest rectangle that contains all the coordinates of that aggregated geometry.

BoundingBox.jpgTo visualize the result on map, you need to transfer the 4 coordinates string into ordinary polygon format, tag the transferred field with certain geopolygon format, drag and drop that field into the map object, then you can see rectangle boxes.

GeoInvProjectGeometry

This function can be used in scripts to aggregate a geometry into an area and apply the inverse of a projection.

GeoInvProjectGeometry(projection, geometry)

GeoProjectGeometry

This function can be used in scripts to aggregate a geometry into an area and apply a projection.

GeoProjectGeometry(projection, geometry)

Non-aggregation functions

There are four non-aggregation geospatial functions in the current release of Qlik Sense (1.0.1).

GeoGetPolygonCenter

This function can be used in scripts and chart expressions to calculate and return the center point of a geometry.

GeoGetPolygonCenter(geometry)

In some case, we want to plot dot instead of color fill on map. If the existing geospatial data is only available in the form of area geometry (e.g. boundary), we need function that can retrieve one pair of longitude and latitude for the center of area. Therefore, GeoGetPolygonCenter() is provided in Qlik Sense.

For example, we can still create bubble map like below to plot the central points of Sydney suburbs, though we only have boundary information in the data source.

AreaVsPoint.jpg

GeoGetBoundingBox

This function can be used in scripts and chart expressions to calculate the smallest GeoBoundingBox that contain all coordinates of a geometry.

A GeoBoundingBox is represented as a list of four values, left, right, top, bottom.

As described in the previous section, with a few extra steps, you can visualize rectangle boxes on a map object.   

GeoProject

This function can be used in scripts and chart expressions to apply a projection to a geometry.

GeoProject(projection, geometry)

This is a projection function for a single geometry. As explained in the previous section, this function will be useful for map areas that are close to the north or south pole.

GeoMakePoint

This function can be used in scripts and chart expressions to create and tag a Point with latitude and longitude.


GeoMakePoint(latitude, longitude)

Those non-aggregation functions can be called in load script. Error message will be thrown if they are used together with "group by" clause.

It's exciting to play with the brand new geospatial functions. When you enjoy discovering more business insights with those out-of-the-box features, please remember, this is just the beginning of Qlik Sense.

Yang Yang - Qlik Senior Solution Architect

6 Comments
fkeuroglian
Partner - Master
Partner - Master

Muy Bueno Arturo!

3,263 Views
Not applicable

many thanks very useful

3,263 Views
reanfadyl
Partner - Creator
Partner - Creator

Hello,

Is the any functions that can be used to calculate whether a XY coordinate falls within a geospatial boundary area?

e.g. The centre of 'London' (defined by X,Y)  is within the 'United Kingdom' (defined by area)

0 Likes
3,263 Views
Not applicable

do you know why Qlik sense (2.1.1) keeps saying that "the hypercube results are too large" when I use map chart to show data, while it works pretty well on version 2.0.2

Trying to find the exactly reason and figure out workarounds for this, my app is dying....

0 Likes
3,263 Views
Not applicable

Hi,

No matter what I do I get error with the function GeoAggrGeometry function. I have used points and even Areas as argument but no luck.

Any ideas what I may be doing wrong ?

0 Likes
3,263 Views
Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

Hello Arturo & others

I would like to understand GeoAggrGeometry() behaviour and how it actually works.

I have loaded some Australia Postcodes to QlikSense.

Qlik Sense is plotting it without issues on Map chart object.

Then i wanted to create groupings for Suburbs, Areas & Territories defined by postcodes and i found it difficult. Qlik Sense in this matter behaves strange. Sometimes it is plotting chart properly and sometimes not.

When i had few postcodes selected and grouped into one area it was OK, once i cleared selection it crashed

On below screenshot we see:

- on left Australia by states (shape files were created based on Australia states) - do not bother

- on right Australia postcodes -- every shape = 1 postcode

- in the middle there are maps for Territory, Area and Suburb but they are not always plotting

snap4.jpg

if i apply selection for example on Territory i am able to plot all 5 maps correctly .

snap5.jpg

Have you ever come across this behavior?

Any suggestions? tips or tricks?

Why there is a JSON protocol parse error?

thanks everyone

0 Likes
3,263 Views