By David Crowther
In a previous FAQ we illustrated how you can use the MapThat LABEL Layers to present statistical information in a dashboard style map for your layers!
For example - the map below shows a Grounds Maintenance site location, where we have exploded the central site point to create 4 displaced points around the edges. These displaced points are then used to show a label related to an attribute of that Site.
The labels show:
- the Maintenance Cost to manage the site
- the number of Vehicles at the site
- the number of Machinery at the site
- a count of assets and equipment held at the site
But how did we do this?... and how can you implement this yourself?
1 – QGIS – Displace Points
Firstly, we will open our Depot/Sites layer from our GeoStore (SQL Server) into QGIS.
We need to generate points, at each location, that are offset in a circular direction, so that we can ultimately position labels around the depot/site.
In QGIS we will use the Points Displacement tool from the Processing Toolbox.
In the Points Displacement tool choose the input layer, and then set the Displacement Distance to be 10 metres.
A temporary scratch layer is then created which creates 4 displaced points from the original depot/site.
The new displaced points will contain the same attributes as the original site/location point that they originated from.
Before we import this file back into our GeoStore, make any attribute changes as needed, for example:
- Add a new column which defines the count/value each point represents – db_no_features
- Add a new column which defines the category each point represents – stat_category
- In this example we will have four categories:
- Maintenance Cost - cost
- Number of Vehicles - vehicles
- Number of Machinery Vehicles - machinery
- Count of Assets/Equipment on site – equipment
- Extract the new Easting and Northing values for the displaced point records into two new fields using the Field Calculator.
With the site locations displaced, and their attributes updated with a record count, the type of category and their X & Y location, simply import the new layer into your GeoStore.
2 – SQL Table
Before we create our MapThat Layers, you will need to undertake some extra updates to the GeoStore table. You could so this in QGIS beforehand or you may find it easier via SSMS.
A – Create 2 new fields to store the coordinates for the labels.
The MapThat Labels Layer allows you to choose the X and Y coordinate fields in your data to position the Labels. However, if as below, you wish to offset the labels from the actual site location….
… you should create 2 extra label coordinate fields, and then update those coordinates to offset the label by X metres in the Easting and Northing direction.
- Use SSMS to add the two extra fields:
- Use a SQL Update statement to update the values in those fields, by using the original Easting and Northing fields and add X metres to each coordinate as needed:
In my example, I also used a WHERE CLAUSE so that I could choose the points to be updated by their category and then choose to move the label either north, south, east, or west a set number of metres e.g. I used this update statement to move the Machinery labels:
update aim_builidng_labels_split set label_northing = northing - 3 where stat_category = 'machinery'
This moved the label location for the machinery stat downwards in the map by 3 metres.
Repeating this to create new Label_Easting and Label_Northing values per displaced point (category), we will now have a table where we can use the original E&N field to render an icon and use the extra LabelX & LabelY fields to position the labels.
B – Create a new Category field in Character format
- One final change I made to the design of my SQL Table, was to add a new STAT/FEATURE COUNT field in CHARACTER format. This meant that I could show the COST values as a CURRENCY value instead of an integer value.
3 – MapThat Configuration
With the data now in the GeoStore and the Fields and Attributes updated as we need them, you can now start the config in MapThat.
A – Sites Icon DataPoint Layer
Use the MapThat Admin Forms to create a DataPoint Layer which renders an icon at the newly displaced point locations.
- Type = DataPoint
- Coordinates = use the source data’s Easting and Northing fields
…… remember that each point has a Category associated to it… so create a THEME within the MapThat Admin forms so we can style the four points accordingly.
Now when the layer renders in MapThat we have the 4 displaced points using a THEME to style the icon as per the category.
B – Sites Label Layer
Use the MapThat Admin Forms to create a LABELS Layer which renders TEXT GEOMETRY to create labels for each point.
- Type = LABELS
- Coordinates = use the newly updated Label_Easting and Label_Northing fields
For the Labels Configuration, use the Stroke and Fill Colour to choose the Labels colour
- Stroke Colour = Black
- Fill Colour = Yellow
For the Labels Configuration, use the Text Size and Label Column to define the value and size of label
- Text Size = 18
- Label Column = your_category_field
In MapThat we now have a Labels Layer that when displayed will use the TEXT values to label each of the 4 displaced points.
Finally, you may wish to make the following MapThat Config changes:
- Create a New Header Tree, containing the:
- Main Sites/Locations layer – centre point
- The Displaced Points Layer – points rotated around the site
- The Labels Layer – to show the count/stat values
- Apply a Tick box to the new Header Tree so the user can display all 3 layers at once
- Choose not to show a TICK box for the Displaced Points and Labels layer, so the user can’t untick them manually.
- Also only show the Displaced Points and Labels Layer at 1 or 2 zoom levels e.g., Zoom 20 and 21. This is because the 5-metre offset for the labels will only work at these zoom levels.
Testing the new layers in MapThat, we now have a dashboard style map, where the displaced points around the site show categories, with the Label layer providing real time and easily accessible stats for that location!
e.g., a Schools Site –
Or a Transport Hub….
… your Plant Rooms….
…and Grounds Maintenance locations
One final config change you can make is to make the DataPoint Layer editable with an associated bubble that reveals the Count/Stat value. Your users can then use the MapThat Drawing Tools to update the statistics in the Dashboard.
Using the Edit Attribute Tool to change the Cost value to a new figure….
… and saving the change…..
… the dashboard map updates for all other users to see the change in the Cost value!
…. Why don’t you take advantage of the MapThat Labels layer type to try and create high impact dashboard style maps like these!
Comments (0 comments)