-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
325 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
--- | ||
title: "Geospatial Analysis with R" | ||
subtitle: Class 1 | ||
output: | ||
xaringan::moon_reader: | ||
lib_dir: libs | ||
css: ["default", "lucy", "middlebury-fonts", "themes/class1.css"] | ||
nature: | ||
highlightStyle: github | ||
highlightLines: true | ||
countIncrementalSlides: false | ||
--- | ||
|
||
```{r setup, include=FALSE} | ||
# knitr::opts_chunk$set(echo = FALSE) | ||
``` | ||
|
||
```{r, eval = FALSE} | ||
library(raster) | ||
library(viridis) | ||
ghana_dem <- getData(name = "alt", country = "GHA") | ||
png("inst/slides/figures/ghana-dem.png", bg = "transparent", height = 4, | ||
width = 3, res = 300, units = "in") | ||
par(mar = c(3, 0, 0, 0)) | ||
plot(as(extent(ghana_dem), "SpatialPolygons"), lty = 0) | ||
plot(ghana_dem, col = magma(100), add = TRUE, axes = FALSE, box = FALSE, | ||
legend = FALSE) | ||
plot(ghana_dem, col = magma(100), legend.only = TRUE, horizontal = TRUE, | ||
axis.args = list(col.axis = "white", col = "white", las = 2), | ||
legend.args = list(text = "", col = "white")) | ||
dev.off() | ||
``` | ||
|
||
--- | ||
|
||
## Class Overview | ||
|
||
- By the end of this class, you should: | ||
- Be comfortable in working with R, including most common geospatial functions | ||
- Have a good sense of where R is headed as a language | ||
- Know where to look when don't know how to do something | ||
- Be using R as part of a ___reproducible___ workflow | ||
|
||
- Course approach | ||
- (Largely) flipped model and emphasis on problem solving | ||
- Programming should be fun! (or at least intriguing) | ||
- Lab and office hours as help sessions | ||
|
||
--- | ||
|
||
## Reproducibility 1 | ||
|
||
```{r, out.width = "70%", echo=FALSE, fig.align='center'} | ||
knitr::include_graphics("figures/class1_1.png") | ||
``` | ||
|
||
--- | ||
|
||
## Reproducibility 2 | ||
```{r, out.width = "50%", echo=FALSE, fig.align='center'} | ||
knitr::include_graphics("figures/class1_2.png") | ||
``` | ||
--- | ||
|
||
## Course Requirements | ||
|
||
- Let's have a look at the [Syllabus](syllabus.html) | ||
- Basic policies | ||
- Attendance and communication | ||
- Attention to detail | ||
|
||
--- | ||
|
||
## Projects | ||
- Projects [page](projects.html) | ||
|
||
--- | ||
|
||
## Getting Set Up/Homework | ||
|
||
- [README](https://github.com/agroimpacts/geospaar) | ||
- Get yourself a GitHub account, if you haven't | ||
- Send us your GitHub name (**!!**) | ||
- Install all necessary software on your local computer(s). | ||
- Set up your [personal access token](https://agroimpacts.github.io/geospaar/git-github.html) | ||
- **Read** Unit1-Module 1 before section 3.2.1, section 1.7 Style in Syllabus, and cheatsheet of RStudio and R markdown. | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,234 @@ | ||
<!DOCTYPE html> | ||
<html lang="" xml:lang=""> | ||
<head> | ||
<title>Geospatial Analysis with R</title> | ||
<meta charset="utf-8" /> | ||
<script src="libs/header-attrs-2.19/header-attrs.js"></script> | ||
<link href="libs/remark-css-0.0.1/default.css" rel="stylesheet" /> | ||
<link href="libs/remark-css-0.0.1/lucy.css" rel="stylesheet" /> | ||
<link href="libs/remark-css-0.0.1/middlebury-fonts.css" rel="stylesheet" /> | ||
<link rel="stylesheet" href="themes/class1.css" type="text/css" /> | ||
</head> | ||
<body> | ||
<textarea id="source"> | ||
class: center, middle, inverse, title-slide | ||
|
||
.title[ | ||
# Geospatial Analysis with R | ||
] | ||
.subtitle[ | ||
## Class 1 | ||
] | ||
|
||
--- | ||
|
||
|
||
|
||
|
||
|
||
```r | ||
library(raster) | ||
library(viridis) | ||
ghana_dem <- getData(name = "alt", country = "GHA") | ||
png("inst/slides/figures/ghana-dem.png", bg = "transparent", height = 4, | ||
width = 3, res = 300, units = "in") | ||
par(mar = c(3, 0, 0, 0)) | ||
plot(as(extent(ghana_dem), "SpatialPolygons"), lty = 0) | ||
plot(ghana_dem, col = magma(100), add = TRUE, axes = FALSE, box = FALSE, | ||
legend = FALSE) | ||
plot(ghana_dem, col = magma(100), legend.only = TRUE, horizontal = TRUE, | ||
axis.args = list(col.axis = "white", col = "white", las = 2), | ||
legend.args = list(text = "", col = "white")) | ||
dev.off() | ||
``` | ||
|
||
--- | ||
|
||
## Class Overview | ||
|
||
- By the end of this class, you should: | ||
- Be comfortable in working with R, including most common geospatial functions | ||
- Have a good sense of where R is headed as a language | ||
- Know where to look when don't know how to do something | ||
- Be using R as part of a ___reproducible___ workflow | ||
|
||
- Course approach | ||
- (Largely) flipped model and emphasis on problem solving | ||
- Programming should be fun! (or at least intriguing) | ||
- Lab and office hours as help sessions | ||
|
||
--- | ||
|
||
## Reproducibility 1 | ||
|
||
<img src="figures/class1_1.png" width="70%" style="display: block; margin: auto;" /> | ||
|
||
--- | ||
|
||
## Reproducibility 2 | ||
<img src="figures/class1_2.png" width="50%" style="display: block; margin: auto;" /> | ||
--- | ||
|
||
## Course Requirements | ||
|
||
- Let's have a look at the [Syllabus](syllabus.html) | ||
- Basic policies | ||
- Attendance and communication | ||
- Attention to detail | ||
|
||
--- | ||
|
||
## Projects | ||
- Projects [page](projects.html) | ||
|
||
--- | ||
|
||
## Getting Set Up/Homework | ||
|
||
- [README](https://github.com/agroimpacts/geospaar) | ||
- Get yourself a GitHub account, if you haven't | ||
- Send us your GitHub name (**!!**) | ||
- Install all necessary software on your local computer(s). | ||
- Set up your [personal access token](https://agroimpacts.github.io/geospaar/git-github.html) | ||
- **Read** Unit1-Module 1 before section 3.2.1, section 1.7 Style in Syllabus, and cheatsheet of RStudio and R markdown. | ||
|
||
|
||
|
||
|
||
|
||
</textarea> | ||
<style data-target="print-only">@media screen {.remark-slide-container{display:block;}.remark-slide-scaler{box-shadow:none;}}</style> | ||
<script src="https://remarkjs.com/downloads/remark-latest.min.js"></script> | ||
<script>var slideshow = remark.create({ | ||
"highlightStyle": "github", | ||
"highlightLines": true, | ||
"countIncrementalSlides": false | ||
}); | ||
if (window.HTMLWidgets) slideshow.on('afterShowSlide', function (slide) { | ||
window.dispatchEvent(new Event('resize')); | ||
}); | ||
(function(d) { | ||
var s = d.createElement("style"), r = d.querySelector(".remark-slide-scaler"); | ||
if (!r) return; | ||
s.type = "text/css"; s.innerHTML = "@page {size: " + r.style.width + " " + r.style.height +"; }"; | ||
d.head.appendChild(s); | ||
})(document); | ||
|
||
(function(d) { | ||
var el = d.getElementsByClassName("remark-slides-area"); | ||
if (!el) return; | ||
var slide, slides = slideshow.getSlides(), els = el[0].children; | ||
for (var i = 1; i < slides.length; i++) { | ||
slide = slides[i]; | ||
if (slide.properties.continued === "true" || slide.properties.count === "false") { | ||
els[i - 1].className += ' has-continuation'; | ||
} | ||
} | ||
var s = d.createElement("style"); | ||
s.type = "text/css"; s.innerHTML = "@media print { .has-continuation { display: none; } }"; | ||
d.head.appendChild(s); | ||
})(document); | ||
// delete the temporary CSS (for displaying all slides initially) when the user | ||
// starts to view slides | ||
(function() { | ||
var deleted = false; | ||
slideshow.on('beforeShowSlide', function(slide) { | ||
if (deleted) return; | ||
var sheets = document.styleSheets, node; | ||
for (var i = 0; i < sheets.length; i++) { | ||
node = sheets[i].ownerNode; | ||
if (node.dataset["target"] !== "print-only") continue; | ||
node.parentNode.removeChild(node); | ||
} | ||
deleted = true; | ||
}); | ||
})(); | ||
// add `data-at-shortcutkeys` attribute to <body> to resolve conflicts with JAWS | ||
// screen reader (see PR #262) | ||
(function(d) { | ||
let res = {}; | ||
d.querySelectorAll('.remark-help-content table tr').forEach(tr => { | ||
const t = tr.querySelector('td:nth-child(2)').innerText; | ||
tr.querySelectorAll('td:first-child .key').forEach(key => { | ||
const k = key.innerText; | ||
if (/^[a-z]$/.test(k)) res[k] = t; // must be a single letter (key) | ||
}); | ||
}); | ||
d.body.setAttribute('data-at-shortcutkeys', JSON.stringify(res)); | ||
})(document); | ||
(function() { | ||
"use strict" | ||
// Replace <script> tags in slides area to make them executable | ||
var scripts = document.querySelectorAll( | ||
'.remark-slides-area .remark-slide-container script' | ||
); | ||
if (!scripts.length) return; | ||
for (var i = 0; i < scripts.length; i++) { | ||
var s = document.createElement('script'); | ||
var code = document.createTextNode(scripts[i].textContent); | ||
s.appendChild(code); | ||
var scriptAttrs = scripts[i].attributes; | ||
for (var j = 0; j < scriptAttrs.length; j++) { | ||
s.setAttribute(scriptAttrs[j].name, scriptAttrs[j].value); | ||
} | ||
scripts[i].parentElement.replaceChild(s, scripts[i]); | ||
} | ||
})(); | ||
(function() { | ||
var links = document.getElementsByTagName('a'); | ||
for (var i = 0; i < links.length; i++) { | ||
if (/^(https?:)?\/\//.test(links[i].getAttribute('href'))) { | ||
links[i].target = '_blank'; | ||
} | ||
} | ||
})(); | ||
// adds .remark-code-has-line-highlighted class to <pre> parent elements | ||
// of code chunks containing highlighted lines with class .remark-code-line-highlighted | ||
(function(d) { | ||
const hlines = d.querySelectorAll('.remark-code-line-highlighted'); | ||
const preParents = []; | ||
const findPreParent = function(line, p = 0) { | ||
if (p > 1) return null; // traverse up no further than grandparent | ||
const el = line.parentElement; | ||
return el.tagName === "PRE" ? el : findPreParent(el, ++p); | ||
}; | ||
|
||
for (let line of hlines) { | ||
let pre = findPreParent(line); | ||
if (pre && !preParents.includes(pre)) preParents.push(pre); | ||
} | ||
preParents.forEach(p => p.classList.add("remark-code-has-line-highlighted")); | ||
})(document);</script> | ||
|
||
<script> | ||
slideshow._releaseMath = function(el) { | ||
var i, text, code, codes = el.getElementsByTagName('code'); | ||
for (i = 0; i < codes.length;) { | ||
code = codes[i]; | ||
if (code.parentNode.tagName !== 'PRE' && code.childElementCount === 0) { | ||
text = code.textContent; | ||
if (/^\\\((.|\s)+\\\)$/.test(text) || /^\\\[(.|\s)+\\\]$/.test(text) || | ||
/^\$\$(.|\s)+\$\$$/.test(text) || | ||
/^\\begin\{([^}]+)\}(.|\s)+\\end\{[^}]+\}$/.test(text)) { | ||
code.outerHTML = code.innerHTML; // remove <code></code> | ||
continue; | ||
} | ||
} | ||
i++; | ||
} | ||
}; | ||
slideshow._releaseMath(document); | ||
</script> | ||
<!-- dynamically load mathjax for compatibility with self-contained --> | ||
<script> | ||
(function () { | ||
var script = document.createElement('script'); | ||
script.type = 'text/javascript'; | ||
script.src = 'https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-MML-AM_CHTML'; | ||
if (location.protocol !== 'file:' && /^https?:/.test(script.src)) | ||
script.src = script.src.replace(/^https?:/, ''); | ||
document.getElementsByTagName('head')[0].appendChild(script); | ||
})(); | ||
</script> | ||
</body> | ||
</html> |