You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _episodes_rmd/12-time-series-raster.Rmd
+57-42Lines changed: 57 additions & 42 deletions
Original file line number
Diff line number
Diff line change
@@ -29,7 +29,7 @@ library(rgdal)
29
29
library(ggplot2)
30
30
library(dplyr)
31
31
library(scales)
32
-
library(reshape)
32
+
library(tidyr)
33
33
```
34
34
35
35
@@ -68,13 +68,14 @@ available from Landsat data. The RGB directory contains RGB images for each time
68
68
period that NDVI is available.
69
69
70
70
### Getting Started
71
-
In this episode, we will use the `raster`, `rgdal`, `reshape`, and `scales` packages. Make sure you have them loaded.
71
+
In this episode, we will use the `raster`, `rgdal`, `scales`, `tidyr`, and `ggplot2` packages. Make sure you have them loaded.
72
72
73
73
```{r, eval = FALSE}
74
74
library(raster)
75
75
library(rgdal)
76
-
library(reshape)
77
76
library(scales)
77
+
library(tidyr)
78
+
library(ggplot2)
78
79
```
79
80
80
81
To begin, we will create a list of raster files using the `list.files()`
@@ -158,14 +159,12 @@ UTM Zone 19.
158
159
## Plotting Time Series Data
159
160
Once we have created our RasterStack, we can visualize our data. We can use
160
161
the `ggplot()` command to create a multi-panelled plot showing each band in our RasterStack. First we
161
-
need to create a data frame object. Because there are multiple bands in our data, we will reshape (or "melt")
162
-
the data so that we have a single column with
163
-
the NDVI observations. We will use the function
164
-
`melt()` from the `reshape` package to do this:
162
+
need to create a data frame object. Because there are multiple columns in our data that are not variables, we will tidy (or "gather") the data so that we have a single column with the NDVI observations.
163
+
We will use the function `gather()` from the `tidyr` package to do this:
0 commit comments