-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathREADME.Rmd
87 lines (59 loc) · 4.77 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file - rmarkdown::render('README.Rmd', output_format = 'github_document', output_file = 'README.md') -->
```{r readme-setup, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "figures/"
)
is_online = curl::has_internet()
```
# Geocomputation with R: Royal Geographic Society workshop
[![Launch Rstudio Binder](http://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/geocompr/RGSWorkshop/master?urlpath=rstudio)
[![Build Status](https://travis-ci.org/Robinlovelace/geocompr.svg?branch=master)](https://travis-ci.org/Robinlovelace/geocompr) [![](https://img.shields.io/docker/automated/robinlovelace/geocompr.svg)](https://hub.docker.com/r/robinlovelace/geocompr/builds/)
This repo contains a workbook to work through the [Geocomputation with R pre-conference workshop](https://www.rgs.org/events/summer-2019/geocomputation-with-r-%E2%80%93-free-workshop-and-reproduc/), an event sponsored by the [QMRG](https://quantile.info/geocomputation-with-r-book-demo-and-reproducible-map-competition/).
It is based on Geocomputation with R, a book by [Robin Lovelace](https://www.robinlovelace.net/), [Jakub Nowosad](https://nowosad.github.io/), and [Jannes Muenchow](http://www.geographie.uni-jena.de/en/Muenchow.html):
> Lovelace, Robin, Jakub Nowosad and Jannes Muenchow (2019). Geocomputation with R. The R Series. CRC Press.
This book has been published by [CRC Press](https://www.crcpress.com/9781138304512) in the [R Series](https://www.crcpress.com/Chapman--HallCRC-The-R-Series/book-series/CRCTHERSER).
The online version of this book is free to read at https://geocompr.robinlovelace.net/.
## Getting started / homework
There are a few things to prepare before attempting these exercises.
Make sure you have a decent computer with enough battery life to last the duration of the course.
This tutorial assumes you have installed a recent version of R, an editor you're comfortable with (we recommend RStudio), and the necessary packages.
If you fail to get the software installed, you can run RStudio in Binder the button at [github.com/geocompr/RGSWorkshop](https://github.com/geocompr/RGSWorkshop):
[![Launch Rstudio Binder](http://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/geocompr/RGSWorkshop/master?urlpath=rstudio)
However, we recommend installing R on your computer before you begin so you can take control of your computing (that binder instance is not for real world applications and you should learn to use R 'in the wild').
To install R on your computer, check out the guidance here: https://geocompr.robinlovelace.net/spatial-class.html#prerequisites
If you're a complete R beginner, it is strongly recommend that you spend some time reading about R and undertaking an introductory tutorial.
Good places to start include:
- Getting started notes from RStudio: https://support.rstudio.com/hc/en-us/articles/201141096-Getting-Started-with-R
- Information on where to look to learn R: https://csgillespie.github.io/efficientR/learning.html
- The free datacamp course: https://www.datacamp.com/courses/free-introduction-to-r
- An introduction to "Why use R for geographic data?": https://geocompr.robinlovelace.net/intro.html#why-use-r-for-geocomputation
The packages we'll can be installed as follows^[
If you're running Mac or Linux, the previous command to install **sf** may not work first time.
These operating systems (OSs) have 'systems requirements' that are described in the package's [README](https://github.com/r-spatial/sf).
Various OS-specific instructions can be found online, such as the article *Installation of R 3.5 on Ubuntu 18.04* on the blog [rtask.thinkr.fr](https://rtask.thinkr.fr/blog/installation-of-r-3-5-on-ubuntu-18-04-lts-and-tips-for-spatial-packages/).
]:
```{r 02-spatial-data-1, eval=FALSE}
install.packages("sf")
install.packages("spData")
```
All the packages needed to reproduce the contents of the book can be installed with the following command: `devtools::install_github("geocompr/geocompkg")` (note: all this will take some time to run - recommended to do before the course).
The necessary packages can be 'loaded' (technically they are attached) with the `library()` function as follows:
```{r 02-spatial-data-3, message=FALSE}
library(sf) # classes and functions for vector data
library(spData) # contains example data
```
## What is geographic data in R?
In R geographic data is just an object like any other.
R's basic data analysis object type is the data frame, which looks like this:
```{r}
world
```
To plot geographic data, do:
```{r world-all, fig.cap="A spatial plot of the world using the sf package, with a facet for each attribute.", warning=FALSE, fig.scap="A spatial plot of the world using the sf package."}
plot(world)
```