We will add a grid visualization and some more indicator scales.
grid visualization, heatmap scale
grid visualization, magma scale
grid visualization, positive scale
grid visualization, negative scale
Using H3 grid
CleverMaps natively supports visualization using the H3 grid spatial index developed by Uber. This hierarchical spatial index consists of several resolutions of grid cells which cover the whole Earth, and are related to each other (similar to lower and higher administrative units). The differences between this approach and using AreaMapper and data dimension are:
The geometries are not in vector tile format, but are generated on the fly by the application frontend
There is no need for pre-computed DWH datasets in the project - H3 grids have generated cell names
The grid can be used for any location on Earth (in any resolution)
The usage is also much simpler - to use the H3 grid visualization we need to:
add some h3Grid datasets (each for one resolution)
add these datasets to the ref.h3Geometries array of the geometryPoint dataset we want to visualize
Is H3 grid insufficient in performance? The use case described here is a basic one. It's possible to use dataset with materialized H3 grid ID columns which makes the responses up to 2-3x times faster.
If you need connect multiple fact tables, it is necessary to use materialized H3 grid dimension with materialized DWH datasets. In the example bellow, the dataset cz_uc4_grid_res9_dwh can be connected with multiple fact datasets from the left side:
CleverMaps AreaMapper is one of our data preparation tools. AreaMapper computes geometric intersection between points and polygons (areas, grids) and then adds ID's of polygons to the points table if an intersection exists.
It can be run in Docker or at Keboola. We will use Docker, because not everyone has a Keboola account and it can be run locally.
You can get Docker here. Select Docker Desktop and download the installation file according to your platform.
Then use following command to get the AreaMapper image:
docker pull clevermaps/areamapper:latest
We will create an empty directory on our local drive (e.g. /home/user/CleverMaps/AreaMapper) and copy the customers.csv file from the first tutorial into the folder.
Now, we will create a configuration file for AreaMapper. There are two possible ways of running AreaMapper:
using polygons CSV on your local drive
using polygons CSV prepared and hosted by us
The difference is - when using local CSV, you can use any CSV you want. When using the hosted CSV, the file has to be hosted by us first. For more info, contact us at email@example.com. Current list of hosted dimensions can be found here.
The CSV we will use in this tutorial is already hosted. In case you want to try the "local" way, or just have a look at the CSV, you can download it here.
Here, we omit a significant amount of the importProject command output for the sake of readability.
Source project: nbutdscdghhg25v4 (can-dim-grid-cz-uber)
Destination project: k5t8mf2a80tay2ng (First project)
Imported datasets: 9
Imported metadata objects: 0
Imported CSV files: 4
To view detailed imported content, use status command.
Now you can make changes, or import another project.
When you're done, use addMetadata command to add the metadata to the project.
To push the data to the project, use pushProject command.
Add the imported files using addMetadata and pushProject.
Now we have to edit the customers dataset. AreaMapper added one column to the end of the CSV file - hex_id. We have to add this property to the end of our dataset. It's foreign key will point to the lowest grid dataset - cz_grid_res9_dwh.
Take a look at the data model to see that the customers and cz_grid_res9_dwh are joined.
Enter the Business overview view, and select the new granularity from the granularity drop down menu.
Now, we have a new visualization available - grid.
Alternatively, select one of the lower levels to get to a bigger detail.
Let's take a look at more indicator scales. So far we've used only the standard (blue) scale.
To try some of them, set following scales for these indicators:
for online_turnover_indicator, set content.scale to "heatmap"
for offline_turnover_indicator, set content.scale to "magma"
for online_ratio_indicator, set content.scale to "positive"
for offline_ratio_indicator, set content.scale to "negative"
Use pushProject to push the indicators and enter the view. Select the grid visualization, select one of the lower levels (e.g. "Cell edge 460 m") and click "Visualize" on the "Online channel turnover" indicator.
But indicators offer way more scales. Feel free to explore them and use them in your projects!