This page is part of a series of blog posts written in preparation of a presentation at the FOSS4G Conference in Brussels (25 October 2018).

Create a thematic map

Now that you have loaded the file Belgium2018.json into R (see instructions here) you may want to create a thematic map.

Please proceed to the R code below to see how to create this map in French or in Dutch.

The package tmap

To create the thematic maps you will use the library tmap.

The package tmap on CRAN:
https://CRAN.R-project.org/package=tmap

If the package is not yet installed, you can install it with the following command:

install.packages("tmap")

Create the thematic map in French

Using the function qtm() you can quickly create a thematic map. And if you use the column NAME_REG_FRE to color the municipaliteis, the French region names will appear in the legend:

library(tmap)

qtm(shp = BE_Municipalities2018,
    title = "La division de la Belgique en régions",
    fill = "NAME_REG_FRE",
    fill.title = "2018\nRégion",
    fill.palette = 
      palette(c("#000000", "#FDDA24", "#EF3340")),
    borders = "grey",
    format = "NLD_wide")

Create the thematic map in Dutch

Using the function qtm() you can quickly create a thematic map. And if you use the column NAME_REG_DUT to color the municipaliteis, the Dutch region names will appear in the legend:

library(tmap)

qtm(shp = BE_Municipalities2018,
    title = "Regionale indeling",
    fill = "NAME_REG_DUT",
    fill.title = "België - 2018\nRegio",
    fill.palette = 
      palette(c("#000000", "#FDDA24", "#EF3340")),
    borders = "grey",
    format = "NLD_wide")