forked from GeoScripting-WUR/Scripting4GeoIntro
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGeoScripting_Concept_Intro.Rmd
More file actions
251 lines (169 loc) · 6.1 KB
/
GeoScripting_Concept_Intro.Rmd
File metadata and controls
251 lines (169 loc) · 6.1 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
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
---
title: "Geo-scripting"
author: "Jan Verbesselt"
date: "`r format(Sys.time(), '%d %B, %Y')`"
output:
ioslides_presentation:
footer: "Geo-scripting 2020"
---
<!--
add explanation on evaluation criteria - rubrics - evaluation and feedback system
add explanation on "reproducible example"
add explanation on test exam
-->
## Did you know?!
Scripting can be used to process satellite data easily to monitor deforestation globally
- Google Earth Engine for global deforestation monitoring
- https://earthengine.google.org/#intro

Image Credit: NASA Goddard, based on data from Hansen et al., 2013.
## Why geo-scripting?

## Why geo-scripting?
- Reproducible: you keep track of what you have done
- Efficient: you can write a script to do something and repeat your analysis x1000...
- Good for finding errors
Can you think of other advantages?
## Why geo-scripting?
- Enable collaboration
- a huge social R and Python community

## Why geo-scripting?
- Build your own tools and functions (e.g. automated web-processing, etc.)

[See Lesson 2 demo's!](https://geoscripting-wur.github.io/Scripting4Geo/#why-scripting)
## Geo-scripting learning objectives
- Read, write, and visualize spatial data using a script
- Find and use functions for geo-data handling
- Know how to find help
- Write a clear and reproducible script
- Learn how to help each other
- Apply learned concepts for your own geo-challenge
<!--
```{block type="alert alert-info"}
```
-->
## The geo-scripting course
Goal:
- Scripting to solve spatial challenges!
- **Learn by doing**
- **Learn how to keep on learning**
A team of `R` & `Python` experts who use geo-scripting languages
every day helped to develop this course
## Course concept
Flipped Classroom concept:

* Experts from companies, research institutes and
university will present (guest lectures)
## Course concept
Day planning See our course guide.
See also Brightspace
- Dayly automatically evaluated Exercises!
## Team work & helping each other
- Teams of two:
- select the team (2 persons, e.g. 1st with 2nd year MGI ) and fill in the form (see blackboard)
- Other teams can be selected for the project work
<div class="centered">

</div>
## Team work & helping each other
- Microsoft teams question and answer Forum
- Microsoft team - Staff announcements
## Scoring
- 3 weekly assignments - 30%
- Questions & Answers support and activity - 10%
- Project - 60%
Details -see the course guide!
## Individual assessment
- Question and answer forum
- DataCamp website: challenges
- Free access to all courses for 6 months
- Script reviewing can be done on an individual basis both team member need to
equally use Git
## Learning outcomes of today:
- Refreshing and assessing R scripting skills to see if you can continue with the course
- Able to write a function
- Know how to visualize a spatial map in R
*Socrative Quiz at the end of this presentation!*
## What is a scripting language?
- A scripting language can interpret and automate the execution of tasks, instead of clicking!!!
- A scripting language is the glue, between different commands, functions, and objectives without the need to compile it for each OS (e.g. windows)
- This is different from like C/C++/Fortran
- these are languages that need to be compiled first.
## Compiling
Passing the source code through a compiler, which translates the `high-level language` instructions into an `exe`.
```{r, echo=FALSE, fig.align='center', fig.width=6, strip.white=TRUE}
library(png)
library(grid)
img <- readPNG("figs/traditionalCompiler.png")
grid.raster(img)
```
## The main scripting languages for GIS and Remote sensing currently are:
- R
- Python
- GRASS (grass function are included in QGIS)
- JavaScript for geoweb scripting
- Matlab
- IDL (ENVI)
- ...
## Python versus R
- Python is a general purpose programming language
- R is particularly strong in statistical computing and graphics
- Syntactic differences between R and Python can be confusing
- There are many R and Python packages for spatial analyses

## R packages

## Many programs have support for
Python & R e.g.:
- QGIS
- GRASS
- PostGIS
## Challenge
Login to socrative: http://www.socrative.com
Room: GEOSCRIPTING
Quiz: Geo-scripting intro
## Time for R action!
- Linux
- Git
- What is a "reproducible script"?
## Reproducibility

## Rubric
[Rubric](https://docs.google.com/document/d/1wdqcrqh4Bt-tNwhEFRa4esq7ozwo36tfOjGmbBTK5B4/edit?usp=sharing)
## Tomorrow morning
- Provide feedback
- Lesson 2
- an overview of what is possible with scripting
- no need to understand the code: lesson 2 is a demonstration lesson!
[See Lesson 2 demo's!](https://geoscripting-wur.github.io/Scripting4Geo/#why-scripting)
<!--
```{r, fig.align='center', echo=FALSE, message=FALSE, eval=FALSE}
if (!file.exists(fn <- "figs/worldcloudRpackage.png")) {
fn <- "figs/worldcloudRpackage.png"
require(XML)
require(tm)
require(wordcloud)
require(RColorBrewer)
u = "http://cran.r-project.org/web/packages/available_packages_by_date.html"
t = readHTMLTable(u)[[1]]
ap.corpus <- Corpus(DataframeSource(data.frame(as.character(t[,3]))))
ap.corpus <- tm_map(ap.corpus, removePunctuation)
# ap.corpus <- tm_map(ap.corpus, tolower)
# txt.corpus <- tm_map(txt.corpus, tolower)
# must be changed to
ap.corpus <- tm_map(ap.corpus, content_transformer(tolower))
ap.corpus <- tm_map(ap.corpus, function(x) removeWords(x, stopwords("english")))
ap.tdm <- TermDocumentMatrix(ap.corpus)
ap.m <- as.matrix(ap.tdm)
ap.v <- sort(rowSums(ap.m),decreasing=TRUE)
ap.d <- data.frame(word = names(ap.v),freq=ap.v)
table(ap.d$freq)
pal2 <- brewer.pal(8,"Dark2")
png(fn, width=1280, height=800)
wordcloud(ap.d$word,ap.d$freq, scale=c(8,.2),min.freq=3,
max.words=Inf, random.order=FALSE, rot.per=.15, colors=pal2)
dev.off()
}
```
-->