We need to have “bank maps” to color in. Two sources:

  1. Dowloaded file.
  2. Provided through an R-package [focus].

Points of attention:

  • We want sf-objects. Frequently already right format, or convert using st_as_sf().
  • Reduce large map to what you need: filter, crop, or limit.
  • Pay attention to included identifier.
# load general packages used below
library(ggplot2)
library(sf)
library(tmap)
library(mapview)

Get maps from downloaded file

Formats: Shapefiles, GeoJSON, KML, etc.

Recommended:

  • Use readOGR() in the rgdal-package: hard to find a format not covered.
  • Convert to simple features-object using

Semi-random example: download the open-data spatial boundaries of the management plans of the Flemish organization for Immovable Heritage.

library(rgdal)
heritage <- readOGR('data/heritage_plans', layer = 'heritage_plans')
## OGR data source with driver: ESRI Shapefile 
## Source: "/home/rstudio/projects/thematic-maps-r/data/heritage_plans", layer: "heritage_plans"
## with 713 features
## It has 6 fields
## Integer64 fields read as strings:  ID
heritage <- st_as_sf(heritage)
qtm(heritage)

mapview(heritage)