Introduction to Spatial Analysis in R
04/10/2019
1 Introduction
In this workshop we are going to work with vector data (points, lines and polygons) and raster data. R has an extraordinary potential to handle this data and perform complex spatial operations like other Geographic Information Systems (GIS) software.
We will explore the capacities of R to handle and manipulate vector data through two worked examples:
Hello, world!
Animal oceanographers
We will also play with raster data with a further two examples:
Introduction to raster data
Working with real world data
Accompanying slides can be downloaded from here
1.1 Set up your working environment
Create a new project within Rstudio. If you are unsure, instructions on how to do this can be found here.
Download the Data.
Unzip and store its contents in a folder named
data
within your new project.Now create the following folders within your project -
output
&img
. This can be done from within R as follows:
- Run the following code to install all required packages:
install.packages(c("rgdal",
"raster",
"viridis",
"leaflet",
"ggplot2",
"mapproj",
"robis",
"gifski",
"elevatr",
"move",
"moveVis",
"dplyr",
"lubridate",
"rgeos",
"adehabitatHR",
"RColorBrewer",
"rasterVis",
"rgl"))
- Once your working environment is set up, you can copy/paste the lines of code from this website into R script(s) to run.