Custom area selection and bookmarking on a GeoAnalytics Map

    I received a request to allow a user to create their own polygon selections on a map (and there may be multiple polygons in a single selection) and be able to save this as a bookmark to be able to retrieve this later. This selection also had to cater for new customer locations etc being created which would still be selected based on the polygons.

     

    This is not an out of the box feature as you might have guessed. When you use the lasoo tool to capture an area on a map (and you can capture multiple areas before selecting) you are selecting the data points within that (those) area(s) and not the area itself. Therefore any new data points (e.g. new customer locations) would not be included in that selection.

     

    Qlik GeoAnalytics can help through a solution that uses a polygon grid at the desired resolution that overlays the map (it can be transparent as required or made not visible until needed). This can then be selected and bookmarked by the user. The actual data points of your locations (in this example customer locations) can then be mapped to this grid using the 'Within' function of the Qlik GeoAnalytics Connector. The steps to recreate are below with an example.

     

    ezgif.com-optimize.gif

     

     

    Step 1 - Use QGIS (open source GIS tool) to create your polygon grid

     

    1.1.  The first information you will require is the maximum and minimum longitude and latitude values of the area you wish to create the grid for. In my example of the UAE I have identified the following min and max values.

     

    Using Google Maps I placed an unknown marker on the map which brings up the coordinates at the bottom which you can highlight and copy. Identify locations that will give you all of the points of the compass for the area; the furthest North, East, South and West points.

    GM2.png

    GM1.png

     

    From these points you can now identify the max and min Latitude from the first number in the point (i.e. 25.2). The max and min Longitude values can be identified from the second number for each point.

     

     

    1.2.  Open QGIS Desktop. I am using version 2.18.10 in this example but you should download the latest version here.

    http://www.qgis.org/en/site/forusers/download.html

     

     

    1.3.  Open a new project, Navigate to Vector > Research Tools > Vector Grid

    QGIS1.png




    1.4. Enter the details for the Grid you wish to create

     

    • Grid Extent = (X) Longitude Min, (X) Longitude Max, (Y) Latitude Min, (Y) Latitude Max (these points you will have defined in step 1.1)
    • X Spacing = The size of the grid on the longitude axis (1 = 1 degree of longitude)
    • Y Spacing = The size of the grid on the latitude axis (1 = 1 degree of longitude)
    • Select Grid type as 'Output grid as polygons'
    • Click Run to create grid layer

    QGIS2.png

     

     

    1.5.  Right click on the new layer that is created and select Save As...

    QGIS3.png

     

     

    1.6.  Fill in the appropriate details for the output of your grid layer

    • Ensure Format is KML
    • Select Geometry Type as Polygon

    QGIS4.png

     

     

     

     

     

     

    Step 2 - Use The GeoAnalytics connector WITHIN function to relate your actual data points to your grid layer.

     

    2.1.  Load the two datasets, actual locations and your grid into an application as normal file based datasources. In my example I have a Customers dataset and the Grid dataset from step 1. I have included the generated code as the highlighted information is important for the following step.

    1.JPG

    2.JPG

    3.JPG

     

    2.2.  Use the within function of the GeoAnalytics connector to relate the two datasets. This will update each time you reload so each new customer will always be assigned to the grid.

     

    Setup a new GeoAnalytics Data Connection (if you don't have on already)

    3a.jpg

     

    Leave as the default Qlik GeoAnalytics online server or enter your local GeoAnalytics server address. Provide a name for the connection ,'GA' in my case, and click save.

     

    NOTE: the online GeoAnalytics server (as below) has a 20,000 record limit for each data set that is passed to it.

    3b.jpg

     

     

    Click on the 'Select' icon of the newly created connection.

    3c.jpg

     

     

    The highlighted areas in step 2.1. above will need to be referenced here manually. They are used to enter data into the two red bounded areas below. Your actual point data (i.e. Customers) will be the first set. The Grid (area) dataset will be the second.

     

    4.JPG

     

    Note: if you have loaded Latitude and Longitude as two separate fields then you will need to change the Table Fields and Geometry Type selections.

    e.g.      Table Fields = Customer_Code, Latitude, Longitude

                Geometry Type = Latitude and Longitude Point

     

     

    Click Next and the following screen will appear. Select the 'WithinAssociations' table as the table you require and click Insert Script.

    5.jpg

     

    2.3.  Reload the application.

     

     

     

     

     

    Step 3 - Setup your map and layers and try the custom selection approach.

     

     

     

    3.1. Drag in a map layer

     

    3.2. Add an area layer from the GeoAnalytics extensions.

      • Assign the GridArea field to the area layer.
      • Change the Maximum Number of Objects in Layer Options to ensure all of your grid can be shown.
      • Make the layer transparent as requried.

    4.png

     

    3.3. Add a bubble layer to show the locations

      • Assign the Customer_Location field as the bubble layer

    7.jpg

     

    NOTE: when in the user view, click on the bubble layer and ensure 'Selectable' is NOT checked.

    0.png

     

     

     

     

    3.2. Use the lasoo tool to select multiple of the grid. You will need to click the lasoo icon each time you wish to select an additional area.

    1.png

     

    Then click the green tick icon to select the areas. You will see the points are filtered as they are related to the grid. However, the points themselves are not shown in the filter. This is an important point as any new customer locations related to these grids will automatically show using this bookmark.

    2.png

     

     

    3.3. Save the selected grid areas as a bookmark for future reference.

    3.png

     

     

     

     

     

    Things to Know:


    • On the Qlik Sense native map object:
      • you can only have a single layer on the map (either a point or a polygon). Users could use the grid approach to select a custom area but that map object will not be able to show anything else.
      • There is a hard limitation of 3,333 polygons on the standard map (the limit is editable in the GeoAnalytics area layer options and does not seem to be limited - I have tested 20,000 plus without issue). However, if your polygon shapes are complex (not a simple shape as I have created) then the data volume increases substantially and performance of rendering such a complex layer would need to be reviewed.
    • When using the GeoAnalytics Connector with the online GeoAnalytics server (i.e. not the local GeoAnalytics Plus or Enterprise deployment) there is a 20,000 record limit when passing data. There is no record limit on the GeoAnalytics Enterprise deployment.