Using Spatial Data with R
Last updated: February 21, 2024
Prerequisites and Preparations
To get the most out of this workshop you should have:
- a basic knowledge of R and/or be familiar with the topics covered in the Introduction to R.
- have a recent version of R and RStudio installed.
Recommended:
Create a new RStudio project
R-spatial
in a new folderR-spatial
.Create a new folder under
R-spatial
and call itdata
.Open up a new R Script file and call it
R-spatial.R
for the code you’ll create during the workshop.If you have your working directory set to
R-spatial
which contains a folder calleddata
you can copy, paste, and run the following lines in R:
download.file("http://bit.ly/R-spatial-data", "R-spatial-data.zip")
unzip("R-spatial-data.zip", exdir = "data")
You can also download the data manually here R-spatial-data.zip and extract them in the data
folder.
- Install and load the following libraries:
- For the mapping section install and load these additional libraries:
classInt
RColorBrewer
ggplot2
tmap
leaflet
(On Mac installing binary version is ok)
References
Lovelace, R., Nowosad, J., Muenchow. J. (2024): Geocomputation with R
Pebesma, E. Bivand, R. (2023): Spatial Data Science
Gimond, M (2023): Intro to GIS and Spatial Analysis
Acknowledgements
Some of the materials for this tutorial are adapted from http://datacarpentry.org