-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathgis_r.html
executable file
·392 lines (262 loc) · 7.97 KB
/
gis_r.html
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
<!DOCTYPE html>
<html>
<head>
<title>Introduction to GIS scripting</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="./img/slides.css">
<!-- <style>
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
@import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
@import url(https://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic);
body { font-family: 'Droid Serif'; }
h1, h2, h3 {
font-family: 'Yanone Kaffeesatz';
font-weight: normal;
}
.remark-code, .remark-inline-code { font-family: 'Ubuntu Mono'; }
#slideshow .slide .content .cols.two .col { width: 48%; }
</style>
-->
</head>
<body>
<textarea id="source">
class: center, middle
# Introduction to GIS scripting
## R for GIS
INBO workshop, 9/11 May 2017
Stijn Van Hoey
https://github.com/stijnvanhoey/course_gis_scripting
---
class: center, middle
# Setup
---
class: center, middle, bgheader
background-image: url(./img/download_course.png)
background-size: cover
---
class: middle
* Go to [https://github.com/stijnvanhoey/course_gis_scripting](https://github.com/stijnvanhoey/course_gis_scripting)
.center[
![:scale 80%](./img/download_course.png)]
* Clone or **download** (a ZIP folder) the course material<br> on your computer
---
class: middle
* In `Rstudio` start a new project (`File` > `New Project...`) inside the `notebooks` folder (option `existing Directory`)
![:scale 100%](./img/RStudio_1.png)
---
class: middle
* In `Rstudio` start a new project (`File` > `New Project...`) inside the `notebooks` folder (option `existing Directory`)
![:scale 100%](./img/RStudio_2.png)
---
class: center, middle
![:scale 80%](https://i.ytimg.com/vi/PlaYMh-u-2w/maxresdefault.jpg)
---
class: center, middle
# Recap
---
class: left, middle
* `Packages` provide new objects (classes) and methods
```R
library('ggplot2')
library('sp')
library('raster')
```
--
* `methods/functions` act on `objects` to do something -> `()`
```R
sum(my_vector)
t(my_df) # transpose data.frame
```
--
* These objects have `characteristics/attributes`
```R
attributes(my_df)
```
--
* These objects can be `sliced` -> `[]`
```R
my_vector[1:10]
my_df[1:10, "occurrenceID"]
```
---
class: left, middle
### Help on a specific `function`
```R
?function_name
```
--
### Looking for `something`?
```R
??searchterm
```
--
### Be lazy. Use `TAB`!
![:scale 25%](./img/tabbutton.jpg)
---
class: middle, center
## Intermezzo!
---
class: middle, center
ask for help
![:scale 60%](./img/postit.jpg)
list your never-to-forget commands
---
class: middle, center
![:scale 100%](./img/issuetracker.png)
<div class="alert alert-danger">
Report bugs, typo's, suggestions... as issues: <a href="https://github.com/stijnvanhoey/course_gis_scripting/issues/new">New issue</a>
</div>
---
# R session planning
* Introduction to the ecosystem
* Handson vector handling
* Handson raster handling
---
class: center, middle
# R GIS ecosystem
#### ## Minimal subset of [Spatial Data packages](https://cran.r-project.org/web/views/Spatial.html)
---
class: center, middle, bgheader
background-image: url(./img/StijnVH-ecosystem-gis-R_overview-1.png)
background-size: cover
---
count: false
class: center, middle, bgheader
background-image: url(./img/StijnVH-ecosystem-gis-R_overview-2.png)
background-size: cover
---
class: center, middle
![:scale 10%](./img/gdal_logo.png)
[GDAL (Geospatial Data Abstraction Library)](http://www.gdal.org/) is the<br>
open source Swiss Army knife<br> for raster and vector geospatial data formats.
--
<br><br><br><br>
<small>Traditionally `GDAL` used to design the raster part of the library, and `OGR` the vector part for Simple Features. Starting with GDAL 2.0, both sides have been more integrated.<small>
---
## GDAL functions: CMD
Available on the command line... with [documentation](http://gdal.org/1.11/gdalwarp.html)...<br>
.center[
![:scale 70%](./img/ogr2ogr_cmd.png)
]
<br><br>
This [online cheat-sheet](https://github.com/dwtkns/gdal-cheat-sheet) is a great resource!
---
## GDAL functions: R
* Import the GDAL library and use it within a script
```R
library(rgdal)
gdal_rasterize(...
```
--
* Write an R function to call a specific GDAL command with `system`
```R
# No library(rgdal) (!)
system(paste('gdalinfo', filename))
```
--
* Use the `gdal_cmd_builder` to call a specific GDAL command (package `gdalUtils`)
```R
gdal_cmd_builder('gdalinfo', parameter_variables,...)
```
---
count: false
class: center, middle, bgheader
background-image: url(./img/StijnVH-ecosystem-gis-R_overview-3.png)
background-size: cover
---
count: false
class: center, middle, bgheader
background-image: url(./img/StijnVH-ecosystem-gis-R_overview-4.png)
background-size: cover
---
count: false
class: center, middle, bgheader
background-image: url(./img/StijnVH-ecosystem-gis-R_overview-5.png)
background-size: cover
---
class: center, middle
# Vector data in R
[`07-gis-r-vectors.Rmd`](notebooks/07-gis-r-vectors.html)
---
class: center, middle
# Raster data in R
[`08-gis-r-rasters.Rmd`](notebooks/08-gis-r-rasters.html)
---
count: false
class: center, middle, bgheader
background-image: url(./img/StijnVH-ecosystem-gis-R_overview-5.png)
background-size: cover
---
count: false
class: center, middle, bgheader
background-image: url(./img/StijnVH-ecosystem-gis-R_overview-6.png)
background-size: cover
---
background-color: #bfbfbf
# ArcPy and R
.center[
[Installation instructions](https://github.com/R-ArcGIS/r-bridge-install) (follow the [`README.md`](https://github.com/R-ArcGIS/r-bridge-install/blob/master/README.md))
![](./img/connect_r_arcgis.png)
[Tutorials](https://r-arcgis.github.io/assets/arcgisbinding-vignette.html) and [examples](https://github.com/R-ArcGIS/r-sample-tools/tree/master/scripts)
]
---
# ArcPy and R
Interaction with the R data types:
* `arc.data2sp`
* `arc.sp2data`
* `arc.shape2sp`
---
class: center, middle
# QGis scripts in R
QGis provides its own set of functionalities in the `processing` library. This can be accessed: access QGIS functionalities from R ([RQGIS](https://github.com/jannes-m/RQGIS)) *vs* <br>run R functions in QGIS
[`Demo` of the latter](http://amsantac.co/blog/en/2015/10/31/qgis-r.html)
Check the information [here](https://docs.qgis.org/2.14/en/docs/training_manual/processing/r_intro.html) to write your own QGIS scripts.
---
count: false
class: center, middle, bgheader
background-image: url(./img/StijnVH-ecosystem-gis-R_overview-7.png)
background-size: cover
---
class: middle
The number 1 resource: [CRAN Task View: Analysis of Spatial Data](https://cran.r-project.org/web/views/Spatial.html)
* [Great overview course](http://rspatial.org)
* [Blog of the spatial tasgroup](http://r-spatial.org/)
* [Cheat-sheet](http://www.maths.lancs.ac.uk/~rowlings/Teaching/UseR2012/cheatsheet.html)
* ...
---
class: center, middle
![:scale 100%](./img/rutils.png)
---
class: center, middle
![:scale 100%](./img/rutils_func.PNG)
---
class: center, middle
![:scale 100%](./img/r_tutorials.png)
---
class: center, middle
## Good luck!
![]()
</textarea>
<!-- <script src="https://gnab.github.io/remark/downloads/remark-latest.min.js">
</script>-->
<script src="./img/remark.min.js" type="text/javascript">
</script>
<script>
var slideshow = remark.create();
</script>
<script>
remark.macros.scale = function (percentage) {
var url = this;
return '<img src="' + url + '" style="width: ' + percentage + '" />';
};
var slideshow = remark.create();
</script>
</script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</body>
</html>