We’ve finally arrived at creating our first maps based on the data we imported and cleaned in the previous sessions. The focus of this first session lies on the package tmap to create maps.

1

Let’s start super simple. Import our enhanced district data. Create a map with only the outline of Germany and one where the districts’ borders are visible. Choose a color of your choice for both maps.

2

In the second step, we want to visualize some information on the German districts contained in the attribute table. Choose a column of interest and create a map. Alternate the map by:

  • add a legend title and change the color palette
  • add a title to the map and change the font color of the title
  • place the legend outside of the map at the bottom
  • change the style to process the color scale (categorization) of your attribute.
Assign your map to an object called ger_map.

Combine the following options with a plus sign:

  • add a legend title and change the color palette: tm_fill(col = "", title = "", palette = "") +
  • add a title to the map and change the font color of the title: tm_layout(title = "", title.color = "") +
  • place the legend outside: tm_legend(legend.outside = TRUE/FALSE, legend.outside.position = "")
  • change the style and categorization: style = ("cat", "fixed", "sd", "equal", "pretty", "quantile", "kmeans", "hclust", "bclust", "fisher", "jenks", "dpih", "headtails", log10_pretty", "cont")
If you run colors(), R returns the names of all built-in colors.
To assign your map to an object, use the arrow <-.