Skip to content
This repository has been archived by the owner on Jan 13, 2021. It is now read-only.

Commit

Permalink
update schedule and raster 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam M. Wilson committed Oct 12, 2017
1 parent 3239b87 commit 105e81a
Show file tree
Hide file tree
Showing 16 changed files with 65 additions and 37 deletions.
14 changes: 10 additions & 4 deletions 05_Raster.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ getData("ISO3")%>%
as.data.frame%>%
filter(NAME=="Tunisia")
country=getData('GADM', country='TUN', level=1)
country=getData('GADM', country='TUN', level=2)
country%>%
gSimplify(0.01)%>%
Expand Down Expand Up @@ -266,7 +266,7 @@ Use `projectRaster()` to _warp_ to a different projection.
`method=` `ngb` (for categorical) or `bilinear` (continuous)

```{r}
r2=projectRaster(r,crs="+proj=sinu +lon_0=0",method = )
r2=projectRaster(r,crs="+proj=sinu +lon_0=0",method = "ngb")
par(mfrow=c(1,2));plot(r);plot(r2)
Expand Down Expand Up @@ -434,8 +434,14 @@ rf_min <- focal(r1, w=matrix(1,11,11), fun=min)
rf_max <- focal(r1, w=matrix(1,11,11), fun=max)
rf_range=rf_max-rf_min
## or just use the range function
rf_range2 <- focal(r1, w=matrix(1,11,11), fun=range)
## or do it all at once
range2=function(x,na.rm=F) {
max(x,na.rm)-min(x,na.rm)
}
rf_range2 <- focal(r1, w=matrix(1,11,11), fun=range2)
plot(rf_range)
plot(rf_range2)
```

Expand Down
Binary file modified 05_Raster_files/figure-html/unnamed-chunk-10-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified 05_Raster_files/figure-html/unnamed-chunk-25-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified 05_Raster_files/figure-html/unnamed-chunk-38-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 7 additions & 7 deletions Schedule.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ Course content is designed to be flexible to accommodate student interest and ab
| 9/14 | **Data Wrangling 2** | Filtering, selecting, joining data sets. Data gymnastics with dplyr. | Homework #1 due before class | 1 |
| 9/21 | **Graphics** | More base graphics (scatterplots, histograms). The _grammar of graphics_: ggplot2 and extensions (ggmap, rasterVis, etc.). | | 2 |
| 9/28 | **Spatial Data** | Spatial Libraries: raster, sp, rgeos, rgdal. Integrating ‘traditional GIS’ analyses with statistical modelling. Data intersection (e.g. connecting points with polygons and rasters), overlays, zonal statistics | Homework # 2 | 3 |
| 10/5 | **Spatial Raster I** | Working with gridded spatial data | Project Proposal Due | 4|
| 10/12 | **Spatial Raster II** | Raster calculations, working with climate datasets. | | 5|
| 10/19 | **Spatial Raster III** | A 'mini' project - looking at sea level rise in Bangladesh | | 6 |
| 10/26 | **Reproducible Research & Literate Programming** | RMarkdown to create dynamic research outputs. Publishing to github/word/html/etc.| Homework # 3 | 7|
| 11/2 | **Weather/Climate Data Processing ** | Processing daily weather data from NOAA | First draft of project for peer assessment | 8 |
| 11/9 | **Satellite Data Processing** | Working with MODIS Satellite data | Peer Evaluation Due | 9 |
| 11/16 | **High Performance Computing & Software Integration** | Parallel processing and high performance computing in R, Calling other programs from within R. | Homework # 4 | 10 |
| 10/5 | **Spatial Raster I** | Working with gridded spatial data | Project Proposal Due 10/10 | 4|
| 10/12 | **Spatial Raster II** | A 'mini' project - looking at sea level rise in Bangladesh | | 5|
| 10/19 | **Reproducible Research & Literate Programming** | RMarkdown to create dynamic research outputs. Publishing to github/word/html/etc. | | 6 |
| 10/26 | **Weather/Climate Data Processing ** | Processing daily weather data from NOAA | Homework # 3 | 7|
| 11/2 | **Satellite Data Processing** | Working with MODIS Satellite data | First draft of project for peer assessment | 8 |
| 11/9 | **High Performance Computing & Software Integration** | Parallel processing and high performance computing in R, Calling other programs from within R. | Peer Evaluation Due | 9 |
| 11/16 | | | Homework # 4 | 10 |
| 11/23 | **Thanksgiving** | (no class) | | |
| 11/30 | **Version Control** | Managing code with "version control"" using Github. | Second draft of project Due 12/1 at midnight | |
| 12/7 | **Final Project Presentations** | | 5 minute presentation of your final project | |
Expand Down
17 changes: 12 additions & 5 deletions docs/05_Raster.html
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ <h2 id="your-turn">Your turn</h2>
filter(NAME==&quot;Tunisia&quot;)</code></pre>
<pre><code>## ISO3 NAME
## 1 TUN Tunisia</code></pre>
<pre class="r"><code>country=getData(&#39;GADM&#39;, country=&#39;TUN&#39;, level=1)
<pre class="r"><code>country=getData(&#39;GADM&#39;, country=&#39;TUN&#39;, level=2)

country%&gt;%
gSimplify(0.01)%&gt;%
Expand Down Expand Up @@ -671,7 +671,7 @@ <h2>Spatial Projections</h2>
<h2>Warping rasters</h2>
<p>Use <code>projectRaster()</code> to <em>warp</em> to a different projection.</p>
<p><code>method=</code> <code>ngb</code> (for categorical) or <code>bilinear</code> (continuous)</p>
<pre class="r"><code>r2=projectRaster(r,crs=&quot;+proj=sinu +lon_0=0&quot;,method = )</code></pre>
<pre class="r"><code>r2=projectRaster(r,crs=&quot;+proj=sinu +lon_0=0&quot;,method = &quot;ngb&quot;)</code></pre>
<pre><code>## Warning in rgdal::rawTransform(projto_int, projfrom, nrow(xy), xy[, 1], :
## 48 projected point(s) not finite</code></pre>
<pre class="r"><code>par(mfrow=c(1,2));plot(r);plot(r2)</code></pre>
Expand Down Expand Up @@ -874,10 +874,17 @@ <h2>Focal (“moving window”)</h2>
rf_max &lt;- focal(r1, w=matrix(1,11,11), fun=max)
rf_range=rf_max-rf_min

## or just use the range function
rf_range2 &lt;- focal(r1, w=matrix(1,11,11), fun=range)
plot(rf_range2)</code></pre>
## or do it all at once
range2=function(x,na.rm=F) {
max(x,na.rm)-min(x,na.rm)
}

rf_range2 &lt;- focal(r1, w=matrix(1,11,11), fun=range2)

plot(rf_range)</code></pre>
<p><img src="05_Raster_files/figure-html/unnamed-chunk-38-1.png" width="2100" /></p>
<pre class="r"><code>plot(rf_range2)</code></pre>
<p><img src="05_Raster_files/figure-html/unnamed-chunk-38-2.png" width="2100" /></p>
<div class="well">
<h2 id="your-turn-3">Your turn</h2>
<p>Plot the focal standard deviation of <code>r1</code> over a 3x3 window.</p>
Expand Down
Binary file modified docs/05_Raster_files/figure-html/unnamed-chunk-10-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/05_Raster_files/figure-html/unnamed-chunk-25-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/05_Raster_files/figure-html/unnamed-chunk-38-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions docs/07_Reproducibile.html
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,11 @@ <h2>Literate statistical programming</h2>
</blockquote>
<p>For example… Let’s calculate the current time in R.</p>
<pre class="r"><code>time &lt;- format(Sys.time(), &quot;%a %d %b %X %Y&quot;)</code></pre>
<pre><code>## Warning in as.POSIXlt.POSIXct(x, tz): unknown timezone &#39;default/America/
## New_York&#39;</code></pre>
<p>The text and R code are interwoven in the output:</p>
<p>The time is <code>`r time`</code></p>
<p>The time is Thu 28 Sep 09:21:22 2017</p>
<p>The time is Thu 12 Oct 13:25:37 2017</p>
</div>
<div id="literate-programming-for-and-against" class="section level2 columns-2">
<h2>Literate programming: for and against</h2>
Expand Down Expand Up @@ -729,8 +731,9 @@ <h2>Step 1: Load packages</h2>
CODE HERE
#```</code></pre>
<p>Load these packages in a code chunk (you may need to install some packages):</p>
<pre class="r"><code>library(dplyr)
library(ggplot2)
<pre class="r"><code>library(dplyr)</code></pre>
<pre><code>## Warning: package &#39;dplyr&#39; was built under R version 3.4.2</code></pre>
<pre class="r"><code>library(ggplot2)
library(maps)
library(spocc)</code></pre>
<blockquote>
Expand Down
Binary file modified docs/07_Reproducibile_files/figure-html/unnamed-chunk-5-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 12 additions & 12 deletions docs/Schedule.html
Original file line number Diff line number Diff line change
Expand Up @@ -454,48 +454,48 @@ <h1 class="title toc-ignore">Course Schedule</h1>
<td align="left">10/5</td>
<td align="left"><strong>Spatial Raster I</strong></td>
<td align="left">Working with gridded spatial data</td>
<td align="left">Project Proposal Due</td>
<td align="left">Project Proposal Due 10/10</td>
<td align="right">4</td>
</tr>
<tr class="odd">
<td align="left">10/12</td>
<td align="left"><strong>Spatial Raster II</strong></td>
<td align="left">Raster calculations, working with climate datasets.</td>
<td align="left">A ‘mini’ project - looking at sea level rise in Bangladesh</td>
<td align="left"></td>
<td align="right">5</td>
</tr>
<tr class="even">
<td align="left">10/19</td>
<td align="left"><strong>Spatial Raster III</strong></td>
<td align="left">A ‘mini’ project - looking at sea level rise in Bangladesh</td>
<td align="left"><strong>Reproducible Research &amp; Literate Programming</strong></td>
<td align="left">RMarkdown to create dynamic research outputs. Publishing to github/word/html/etc.</td>
<td align="left"></td>
<td align="right">6</td>
</tr>
<tr class="odd">
<td align="left">10/26</td>
<td align="left"><strong>Reproducible Research &amp; Literate Programming</strong></td>
<td align="left">RMarkdown to create dynamic research outputs. Publishing to github/word/html/etc.</td>
<td align="left"><strong>Weather/Climate Data Processing </strong></td>
<td align="left">Processing daily weather data from NOAA</td>
<td align="left">Homework # 3</td>
<td align="right">7</td>
</tr>
<tr class="even">
<td align="left">11/2</td>
<td align="left"><strong>Weather/Climate Data Processing </strong></td>
<td align="left">Processing daily weather data from NOAA</td>
<td align="left"><strong>Satellite Data Processing</strong></td>
<td align="left">Working with MODIS Satellite data</td>
<td align="left">First draft of project for peer assessment</td>
<td align="right">8</td>
</tr>
<tr class="odd">
<td align="left">11/9</td>
<td align="left"><strong>Satellite Data Processing</strong></td>
<td align="left">Working with MODIS Satellite data</td>
<td align="left"><strong>High Performance Computing &amp; Software Integration</strong></td>
<td align="left">Parallel processing and high performance computing in R, Calling other programs from within R.</td>
<td align="left">Peer Evaluation Due</td>
<td align="right">9</td>
</tr>
<tr class="even">
<td align="left">11/16</td>
<td align="left"><strong>High Performance Computing &amp; Software Integration</strong></td>
<td align="left">Parallel processing and high performance computing in R, Calling other programs from within R.</td>
<td align="left"></td>
<td align="left"></td>
<td align="left">Homework # 4</td>
<td align="right">10</td>
</tr>
Expand Down
12 changes: 9 additions & 3 deletions docs/scripts/05_Raster.R
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ projection(r)
#' `method=` `ngb` (for categorical) or `bilinear` (continuous)
#'
## ------------------------------------------------------------------------
r2=projectRaster(r,crs="+proj=sinu +lon_0=0",method = )
r2=projectRaster(r,crs="+proj=sinu +lon_0=0",method = "ngb")

par(mfrow=c(1,2));plot(r);plot(r2)

Expand Down Expand Up @@ -408,8 +408,14 @@ rf_min <- focal(r1, w=matrix(1,11,11), fun=min)
rf_max <- focal(r1, w=matrix(1,11,11), fun=max)
rf_range=rf_max-rf_min

## or just use the range function
rf_range2 <- focal(r1, w=matrix(1,11,11), fun=range)
## or do it all at once
range2=function(x,na.rm=F) {
max(x,na.rm)-min(x,na.rm)
}

rf_range2 <- focal(r1, w=matrix(1,11,11), fun=range2)

plot(rf_range)
plot(rf_range2)

#'
Expand Down
12 changes: 9 additions & 3 deletions scripts/05_Raster.R
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ projection(r)
#' `method=` `ngb` (for categorical) or `bilinear` (continuous)
#'
## ------------------------------------------------------------------------
r2=projectRaster(r,crs="+proj=sinu +lon_0=0",method = )
r2=projectRaster(r,crs="+proj=sinu +lon_0=0",method = "ngb")

par(mfrow=c(1,2));plot(r);plot(r2)

Expand Down Expand Up @@ -408,8 +408,14 @@ rf_min <- focal(r1, w=matrix(1,11,11), fun=min)
rf_max <- focal(r1, w=matrix(1,11,11), fun=max)
rf_range=rf_max-rf_min

## or just use the range function
rf_range2 <- focal(r1, w=matrix(1,11,11), fun=range)
## or do it all at once
range2=function(x,na.rm=F) {
max(x,na.rm)-min(x,na.rm)
}

rf_range2 <- focal(r1, w=matrix(1,11,11), fun=range2)

plot(rf_range)
plot(rf_range2)

#'
Expand Down

0 comments on commit 105e81a

Please sign in to comment.