In the previous chapters, you were introduced to the basics of
"ggplot2", performing various operations on the data
storms. Because this
data set contains geographical information such as longitude and latitude, in
this part we take a further step to learn about plotting basic, and not so
basic, maps with
"ggplot2" as well as with some dedicated packages to
create maps in R.
Keep in mind that there is a wide array of packages for graphing all sorts of maps, and geospatial information. Good resources to look at are:
Drawing beautiful maps programmatically with R, sf and ggplot2 by Mel Moreno and Mathieu Basille; https://www.r-spatial.org/r/2018/10/25/ggplot2-sf.html
Geocomputation with R by Robin Lovelace, Jakub Nowosad, and Jannes Muenchow; https://r.geocompx.org/t
Making Maps with R by Eric C. Anderson; https://eriqande.github.io/rep-res-web/lectures/making-maps-with-R.html
__From: Geocomputation with __R
“There are many ways to handle geographic data in R, with dozens of packages in the area.”
R’s spatial ecosystem has evolved and keeps evolving at a fast pace.
An inflection point in the development of R’s geospatial tools was the project
Simple Features, an open-source standard and model to store and access vector
geometries. This resulted in the
I’m going to focus on the following packages. Please keep in mind that the packages listed below are by no means a comprehensive set of tools for making maps in R.
sf: Simple Features provides classes and functions for vector data
tmap: Thematic Maps for static and interactive maps
leaflet: for interactive maps
maps: maps data sets
rnaturalearth: maps data sets
As Lovelace, Nowosad and Muenchow state: “The vector data model represents the world using points, lines and polygons. These have discrete, well-defined borders, meaning that vector datasets usually have a high level of precision. The raster data model divides the surface up into cells of constant size. Raster datasets are the basis of background images used in web-mapping and have been a vital source of geographic data since the origins of aerial photography and satellite-based remote sensing devices.”
From Lovelace, Nowosad and Muenchow: reasons for using
Fast reading and writing of data
Enhanced plotting performance
sfobjects can be treated as data frames in most operations
sffunction names are relatively consistent and intuitive (all begin with
sffunctions can be combined with the
|>operator and works well with the tidyverse collection of R packages.