Skip to content

Commit

Permalink
[custom] fix lesson contents
Browse files Browse the repository at this point in the history
  • Loading branch information
zkamvar authored and Carpentries Apprentice committed Feb 7, 2023
1 parent ee731d1 commit af3e28c
Show file tree
Hide file tree
Showing 18 changed files with 555 additions and 66 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
^renv$
^renv\.lock$
^\.travis\.yml$
^appveyor\.yml$
^tic\.R$
2 changes: 1 addition & 1 deletion episodes/01-raster-structure.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ source: Rmd
---

```{r setup, echo=FALSE}
source("../setup.R")
source("setup.R")
knitr::opts_chunk$set(fig.height = 6)
```

Expand Down
2 changes: 1 addition & 1 deletion episodes/02-raster-plot.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ source: Rmd
---

```{r setup, echo=FALSE}
source("../setup.R")
source("setup.R")
```

::::::::::::::::::::::::::::::::::::::: objectives
Expand Down
70 changes: 37 additions & 33 deletions episodes/03-raster-reproject-in-r.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ source: Rmd
---

```{r setup, echo=FALSE}
source("../setup.R")
source("setup.R")
```

::::::::::::::::::::::::::::::::::::::: objectives
Expand Down Expand Up @@ -296,38 +296,42 @@ field site using the `SJER_DSMhill_WGS84.tif` and `SJER_dsmCrop.tif` files.

Reproject the data as necessary to make things line up!

> ## Answers
>
> ```{r challenge-code-reprojection, echo=TRUE}
> # import DSM
> DSM_SJER <- raster("data/NEON-DS-Airborne-Remote-Sensing/SJER/DSM/SJER_dsmCrop.tif")
> # import DSM hillshade
> DSM_hill_SJER_WGS <-
> raster("data/NEON-DS-Airborne-Remote-Sensing/SJER/DSM/SJER_DSMhill_WGS84.tif")
>
> # reproject raster
> DTM_hill_UTMZ18N_SJER <- projectRaster(DSM_hill_SJER_WGS,
> crs = crs(DSM_SJER),
> res = 1)
>
> # convert to data.frames
> DSM_SJER_df <- as.data.frame(DSM_SJER, xy = TRUE)
>
> DSM_hill_SJER_df <- as.data.frame(DTM_hill_UTMZ18N_SJER, xy = TRUE)
>
> ggplot() +
> geom_raster(data = DSM_hill_SJER_df,
> aes(x = x, y = y,
> alpha = SJER_DSMhill_WGS84)
> ) +
> geom_raster(data = DSM_SJER_df,
> aes(x = x, y = y,
> fill = SJER_dsmCrop,
> alpha=0.8)
> ) +
> scale_fill_gradientn(name = "Elevation", colors = terrain.colors(10)) +
> coord_quickmap()
> ```
::::::::::::::: solution

## Answers

```{r challenge-code-reprojection, echo=TRUE}
# import DSM
DSM_SJER <- raster("data/NEON-DS-Airborne-Remote-Sensing/SJER/DSM/SJER_dsmCrop.tif")
# import DSM hillshade
DSM_hill_SJER_WGS <-
raster("data/NEON-DS-Airborne-Remote-Sensing/SJER/DSM/SJER_DSMhill_WGS84.tif")
# reproject raster
DTM_hill_UTMZ18N_SJER <- projectRaster(DSM_hill_SJER_WGS,
crs = crs(DSM_SJER),
res = 1)
# convert to data.frames
DSM_SJER_df <- as.data.frame(DSM_SJER, xy = TRUE)
DSM_hill_SJER_df <- as.data.frame(DTM_hill_UTMZ18N_SJER, xy = TRUE)
ggplot() +
geom_raster(data = DSM_hill_SJER_df,
aes(x = x, y = y,
alpha = SJER_DSMhill_WGS84)
) +
geom_raster(data = DSM_SJER_df,
aes(x = x, y = y,
fill = SJER_dsmCrop,
alpha=0.8)
) +
scale_fill_gradientn(name = "Elevation", colors = terrain.colors(10)) +
coord_quickmap()
```

:::::::::::::::::::::::::

If you completed the San Joaquin plotting challenge in the
[Plot Raster Data in R](02-raster-plot/)
Expand Down
2 changes: 1 addition & 1 deletion episodes/04-raster-calculations-in-r.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ source: Rmd
---

```{r setup, echo=FALSE}
source("../setup.R")
source("setup.R")
```

::::::::::::::::::::::::::::::::::::::: objectives
Expand Down
2 changes: 1 addition & 1 deletion episodes/05-raster-multi-band-in-r.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ source: Rmd
---

```{r setup, echo=FALSE}
source("../setup.R")
source("setup.R")
```

::::::::::::::::::::::::::::::::::::::: objectives
Expand Down
2 changes: 1 addition & 1 deletion episodes/06-vector-open-shapefile-in-r.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ source: Rmd
---

```{r setup, echo=FALSE}
source("../setup.R")
source("setup.R")
```

::::::::::::::::::::::::::::::::::::::: objectives
Expand Down
2 changes: 1 addition & 1 deletion episodes/07-vector-shapefile-attributes-in-r.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ source: Rmd
---

```{r setup, echo=FALSE}
source("../setup.R")
source("setup.R")
```

::::::::::::::::::::::::::::::::::::::: objectives
Expand Down
2 changes: 1 addition & 1 deletion episodes/08-vector-plot-shapefiles-custom-legend.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ source: Rmd
---

```{r setup, echo=FALSE}
source("../setup.R")
source("setup.R")
```

::::::::::::::::::::::::::::::::::::::: objectives
Expand Down
2 changes: 1 addition & 1 deletion episodes/09-vector-when-data-dont-line-up-crs.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ source: Rmd
---

```{r setup, echo=FALSE}
source("../setup.R")
source("setup.R")
```

::::::::::::::::::::::::::::::::::::::: objectives
Expand Down
2 changes: 1 addition & 1 deletion episodes/10-vector-csv-to-shapefile-in-r.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ source: Rmd
---

```{r setup, echo=FALSE}
source("../setup.R")
source("setup.R")
```

::::::::::::::::::::::::::::::::::::::: objectives
Expand Down
2 changes: 1 addition & 1 deletion episodes/11-vector-raster-integration.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ source: Rmd
---

```{r setup, echo=FALSE}
source("../setup.R")
source("setup.R")
```

::::::::::::::::::::::::::::::::::::::: objectives
Expand Down
2 changes: 1 addition & 1 deletion episodes/12-time-series-raster.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ source: Rmd
---

```{r setup, echo=FALSE}
source("../setup.R")
source("setup.R")
```

::::::::::::::::::::::::::::::::::::::: objectives
Expand Down
2 changes: 1 addition & 1 deletion episodes/13-plot-time-series-rasters-in-r.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ source: Rmd
---

```{r setup, echo=FALSE}
source("../setup.R")
source("setup.R")
```

::::::::::::::::::::::::::::::::::::::: objectives
Expand Down
2 changes: 1 addition & 1 deletion episodes/14-extract-ndvi-from-rasters-in-r.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ source: Rmd
---

```{r setup, echo=FALSE}
source("../setup.R")
source("setup.R")
```

::::::::::::::::::::::::::::::::::::::: objectives
Expand Down
1 change: 1 addition & 0 deletions setup.R → episodes/setup.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
options(timeout = max(300, getOption('timeout')))
## file structure

if (! file.exists("data/NEON-DS-Site-Layout-Files")) {
Expand Down
Loading

0 comments on commit af3e28c

Please sign in to comment.