Qgis Tutorial-Dynamic Infographic Map v1
Qgis Tutorial-Dynamic Infographic Map v1
The purpose of this tutorial is to show how to make a design map using
QGIS and DataPlotly with the use of variables. It’s just my point of view and not an
official tutorial or best practice, but I hope you’ll enjoy to use it.
In this tutorial we will suppose that you already have QGIS installed and
we’ll need QGIS 3.24 Tsiler. We will use Openstreetmap data (“© OpenStreetMap
contributors”) with QuickOSM (Etienne Trimaille) and Dataplotly (Matteo Ghetta)
for charts. And to promote my country we will use Reunion Island data (but you
dan use another dataset)
Here I’ll use Poppins fonts from Google Fonts but you can use one of your choice
Install QuickOSM and Dataplotly. Select “All plugins” and in search bar add
the name of the required plugin then click install.
2 - Get data with QuickOSM
Launch QuickOSM
Then to get Reunion Island data just set QuickOSM, in quick query add
“admin_level” as key and “8” to value, then go down.
Set “in” and add “reunion”, extend “Advanced” and uncheck “Lines” and
“Multilinestrings” not needed for this tutorial. Then set the “Directory” to use to save
data and to finish click “Run query”. Of course, you can set other country and
parameter fitting your needs
Be careful, this step is used only for this dataset and may be different with
another.
In the “query builder” window drop down “Fields” and double click to add it to the
query then add “IS NOT NULL” or “NOT NULL”
Otherwise you can just add the text manually or copy & paste it form here :
This query will filter points to get all the points wee need to label the map.
You should now have something like this.
Our municipalities can be group and we will add a new field “EPCI” to set it with an
expression. First, for a better understanding, rename points as “labels” and
polygons as “municipalities”
Select municipalities and open field calculator
Set field like this “Output field name” set “EPCI”, “Text (string)” as “Type” and a
length of “10” should be enough
Then add this expression:
CASE
WHEN "name" IN ( 'La Possession' , 'Le Port' , 'Les Trois-Bassins' , 'Saint-Leu' , 'Saint-
Paul' ) THEN 'TCO'
ELSE ''
END
Click “OK” then now your layer is in edit mode click on save icon to save changes
in the layer. Next click on the pen to toggle off edit mode.
color_1 #F20544
color_2 #4B83F2
color_3 #05F283
color_4 #FFC000
color_5 #C8C5D9
color_dark #131E40
You can remove the last category that contain elements with no values because
our expression should have set all values.
Here each municipality will take color depending on his EPCI name.
A default color palette will be set and we have now to set it with our colors.
Double-click on first category and select simple fill, then click on the button on the
right of the color, select variable and then color_1
Now double-click on labels to set symbology. Choose “Single Symbol” and then
select “Single Marker”. Use white for “fill color” and set “Stroke color” to our variable
“color_dark”.
Now we will set label using background, round borders, callouts, shadows and
some positioning settings. There are so many options for labeling but we will see
just a little part.
Next, on “Background” check “Draw background“, set “Size X” to 3 points, “X” and “Y”
“Radius” to 2 points and because of Poppins font gap set “Y” offset” to “1,5” points.
Then set the symbology of the shape under “Shape” by clicking on it.
In background symbol, select “Simple Fill”, white for “Fill color” and use our
“color_dark” variable for “Stroke color”
And to finish in “Callouts”, check “Draw callouts”, “Offset from feature” to “1,2” and
click on “Line style”.
In “Callout Symbol” select “simple line” and set color to our variable “color_dark”
You should now have a map like this.
The new panel is pretty similar to label panel. Set your font to a Black type if
possible, use an amazing size and chose a light color
You may have to change font, position and other parameters depending on the
font you choose. You can check lock elements to not be disturbed by these blocs
later.
Add a map bloc and in item properties, uncheck “Background” to remove white
background
Add a legend bloc and name it as you like (but we always add legend ) and set
parameters on Item properties. Remove background like for map, uncheck “Auto
update” and customize on your need. For me remove “labels”, set fonts and
rename municipalities
Add a North arrow on the map, select you SVG images and set parameter as you
like. Here “Fill color” to “color_5” and “Stroke color” to “color_dark”
Now we will add color corresponding to map and using our variables. Click on the
button next to “Bar color” and select “Edit”
Add the expression below, it’s an expression to map a color to a specific value of a
field
map_get(
map(
'CASUD',@color_1,
'CINOR',@color_2,
'CIREST',@color_3,
'CIVIS',@color_4,
'TCO',@color_5),"EPCI"
)
Add the same expression to “Stroke color” and update plot to get this
In the “Layout Options”, add these texts and set up your font with bigger sizes. Then
update the plot
For a second chart you can just copy & paste the first chart bloc. Then change
information corresponding to this, now we have density expression
to_real(“population”)/($area/1000). Change the title in “Layout Options” and
update plot
Add text with the text bloc and set the font size to correspond your needs.
We will alternate between different font size and font type to have some text that
can be aligned. For the next text we will use an expression to get population from
the “municipalities” layer with an aggregate function.
aggregate( 'municipalities','sum',to_real("population"))/1000
I divided it by 1000 to use “K” unite, just add a “K” next the expression and set your
font
aggregate( 'municipalities','count',$id)
Adjust elements positions and add a title of your choice
Of course, you’ll have to choose colors depending on what you want to show so
be careful. A graduated color should be used with symbology graduated for
example graduate color by population value. But there are much more steps to
do it with our dataset. If you want to know how, just let me know…
I hope you enjoyed this tutorial, don’t hesitate to contact me on twitter @Oneil974