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.
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.
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.
1.3. Open a new project, Navigate to Vector > Research Tools > Vector Grid
1.4. Enter the details for the Grid you wish to create
1.5. Right click on the new layer that is created and select Save As...
1.6. Fill in the appropriate details for the output of your grid layer
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.
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)
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.
Click on the 'Select' icon of the newly created connection.
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.
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.
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.
3.3. Add a bubble layer to show the locations
NOTE: when in the user view, click on the bubble layer and ensure 'Selectable' is NOT checked.
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.
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.
3.3. Save the selected grid areas as a bookmark for future reference.
Things to Know: