Introduction to R and RStudioProject management in RStudioIntroduction to R


Figure 1

RStudio project logo with five lines, each leading from the logo towards one of the five boxes with texts: 'data/', 'data_output/', 'documents/', 'fig_output/', 'scripts/'
R project organization

Data Structures


Exploring Data Frames & Data frame Manipulation with dplyrExploring Data framesData frame Manipulation with dplyr


Figure 1

A data frame
Source: Data Carpentry R for Social Scientists


Introduction to visualisationIntroduction to VisualisationWriting data


Figure 1


Figure 2


Figure 3


Figure 4


Figure 5


Figure 6


Figure 7


Figure 8


Introduction to Geospatial Concepts


Figure 1

The shape of the Earth. Source: United Nations Statistics Division and International Cartographic Association (2012).
The shape of the Earth. Source: United Nations Statistics Division and International Cartographic Association (2012).

Figure 2

Geographical latitude and longitude. Source: van der Marel (2014).
Geographical latitude and longitude. Source: van der Marel (2014).

Figure 3

Map projection represented as flattening an orange peel. Source: Data Carpentry (2023).
Map projection represented as flattening an orange peel. Source: Data Carpentry (2023).

Figure 4

Cylindrical, conic, and azimuthal map projections. Source: Knippers (2009).
Cylindrical, conic, and azimuthal map projections. Source: Knippers (2009).

Figure 5

Rotterdam in two different CRS
Rotterdam in two different CRS

Figure 6


Figure 7

Same geographical area as raster and vector data
Same geographical area as raster and vector data

Figure 8

Same geographical area as raster and vector data (Source: Saab, 2003)
Same geographical area as raster and vector data (Source: Saab, 2003)

Open and Plot Vector Layers


Figure 1

Geometry in QGIS
Geometry in QGIS

Figure 2

Geometry in R
Geometry in R

Figure 3


Explore and plot by vector layer attributesQuery Vector Feature Metadata


Figure 1

Map of cycleways in Delft.
Map of cycleways in Delft.

Figure 2


Figure 3


Figure 4


Figure 5


Plot multiple shapefiles


Figure 1


Figure 2


Figure 3


Figure 4


Handling Spatial Projections & CRS


Figure 1


Figure 2


Figure 3


Figure 4


Intro to Raster Data


Figure 1

Raster plot with `ggplot2` using the viridis color scale
Raster plot with ggplot2 using the viridis color scale

Figure 2

Single- and multi-band raster
Single- and multi-band raster

Plot Raster Data


Figure 1


Figure 2


Figure 3

The plot above uses the default colours inside ggplot2 for raster objects. We can specify our own colours to make the plot look a little nicer. R has a built in set of colours for plotting terrain available through the terrain.colors() function. Since we have three bins, we want to create a 3-colour palette:


Figure 4


Figure 5

The axis labels x and y are not necessary, so we can turn them off by passing element_blank() to the axis.title argument in the theme() function.


Figure 6


Figure 7


Reproject Raster Data


Figure 1

The difference between DSM and DTM. Source: National Ecological Observatory Network (NEON).
The difference between DSM and DTM. Source: National Ecological Observatory Network (NEON).

Figure 2

Our results are curious - neither the DTM (DTM_TUD_df) nor the hillshade (DTM_hill_TUD_df) are plotted. Let’s try to plot the DTM on its own to make sure the data are there.


Figure 3


Figure 4


Figure 5


Raster Calculations


Figure 1

Source: National Ecological Observatory Network (NEON).
Source: National Ecological Observatory Network (NEON).

Figure 2


Figure 3


Figure 4


Figure 5

Notice that the range of values for the output CHM starts right below 0 and ranges to almost 100 meters. Does this make sense for buildings and trees in Delft?


Figure 6


Figure 7


Work with Multi-Band Rasters


Figure 1


Figure 2


Figure 3


Figure 4


Import and Visualise OSM Data


Figure 1

The result looks like this:


Figure 2

Brielle, Netherlands
Brielle, Netherlands

Figure 3

Brielle, New Jersey
Brielle, New Jersey

Figure 4

The OSMdata Documentation page
The OSMdata Documentation page

Figure 5

The Overpass Query Documentation page
The Overpass Query Documentation page

Figure 6


Figure 7


Figure 8


Basic GIS operations with R and sf


Figure 1


Figure 2


Figure 3


Figure 4


Figure 5


Figure 6


Figure 7