forked from GeoScripting-WUR/IntroToRaster
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathslides.Rmd
More file actions
112 lines (69 loc) · 2.02 KB
/
slides.Rmd
File metadata and controls
112 lines (69 loc) · 2.02 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
---
title: "Intro to Raster"
author: "Loïc Dutrieux, Jan Verbesselt"
date: "01/08/2015"
output: slidy_presentation
---
# Yesterday
Project including function to check whether an input year is a leap year or not.
<center>
<h2>Who submitted</h2>
</center>
```{r, echo=FALSE, results = 'asis'}
suppressPackageStartupMessages(library(googleVis))
x <- data.frame(status = "submitted", n = 13)
pie <- gvisPieChart(data = x)
print('<center>')
print(pie)
print('</center>')
```
---
Well structured projects
`'error: argument of class numeric expected'` instead of `error()`
```{r, eval = FALSE}
rprint("No Leap Year")
## instead of
return()
## at the end of a function.
```
```{r, eval=FALSE}
return(year%%4==0)
```
---
# Today
Morning
* Go through [tutorial](http://geoscripting-wur.github.io/IntroToRaster/)
Afternoon
* Quick overview of the tutorial
* Exercise
---
# The raster objects (classes)
```{r, echo=FALSE, results='asis'}
library(knitr)
df <- data.frame(Class = c('RasterLayer', 'RasterBrick', 'RasterStack'), Description = c('Single layer raster object', 'Multiple Layer Raster object', 'Multiple Layer Raster object'))
kable(df)
```
* `raster()`
* `brick()`
* `stack()`
* `writeRaster()`
---
# Simple Raster calculations / raster arithmetic
Raster arithmetic follows simple R vector arithmetic rules.
* Value replacement
* Additions, substractions, etc
**Although warning, not memory safe for big rasters:**
* Instead, `calc()` and `overlay()` should be used.
---
# calc() and overlay()
* Both function implement block processing (no memory limitation)
* `calc()` mostly for applying a function to single raster objects
* `overlay()` makes it easier to implement function that involve multiple raster objects
* These functions are only suitable for pixel based calculation
* Can write output directly to disk (see `filename =` argument)
---
# Visualize raster data
* `plot()`
* `plotRGB()`
* On google Earth by converting to KML format or using `plotKML` package
Also possible using `ggplot2` and `rasterVis` package