-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_targets.Rmd
96 lines (72 loc) · 2.79 KB
/
run_targets.Rmd
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
---
title: "Run Targets - Landsat Collection 2 SR/ST Acquisition"
date: "`r Sys.Date()`"
author: "ROSSyndicate"
output:
html_document: default
pdf_document: default
---
# Purpose
This is a helper script that loads all necessary packages to run the targets
pipeline, then runs it to acquire Landsat Collection 2 surface reflectance and
surface temperature for user-defined areas of interest (AOI). While this script
is written in an .Rmd script, we recommend walking through this script manually,
as the knit function often runs into issues and this script has a number of
interactive steps.
## Install necessary packages
```{r package_installer, echo = F}
package_installer <- function(x) {
if (x %in% installed.packages()) {
print(paste0('{', x ,'} package is already installed.'))
} else {
install.packages(x)
print(paste0('{', x ,'} package has been installed.'))
}
}
```
List packages that need to be checked for install, and walk the function along them all.
```{r walk_package_installer, message = F}
packages <- c('tidyverse',
'reticulate',
'targets',
'tarchetypes',
'yaml',
'nhdplusTools',
'polylabelr',
'sf')
lapply(packages, package_installer)
```
## Authenticate and initialize Earth Engine
You will need to have [installed and initialized the `gcloud CLI`](https://cloud.google.com/sdk/docs/install)
and have a [Google Earth Engine account](https://code.earthengine.google.com/register)
prior to running this workflow. Some common troubleshooting solutions
[can be found here]<https://github.com/rossyndicate/ROSS_RS_mini_tools/blob/main/helps/CommonIssues.md>).
### Authentication
To authenticate your GEE account, we will use a Python environment created in the
R file 'data_acquisition/src/py/pySetup.R'. This will take a few minutes if you
haven't yet run the python setup script while it creates a virtual environment.
```{r}
source('data_acquisition/py/pySetup.R')
```
### Authenticate your instance of GEE
```{python}
import ee
ee.Authenticate(auth_mode = 'localhost')
```
## Run the targets pipeline and output a network graph.
Prior to running this pipeline, you'll need to populate the `config.yml` file
with the information for the Landsat Surface Reflectance and Surface Temperature
Collection 2 product stack pull. Additionally, you will need to change line 5 of
the `_targets.R` file if you have renamed the config file from `config.yml`.
If you wish to run the example_config.yml pull, you will need to change the following
.yml settings to those associated with your computer and/or google account information:
- Line 8: data_dir
- Line 20: google_email
- Line 23: ee_proj
```{r run_targets, echo = F}
library(targets)
{
tar_make()
tar_visnetwork()
}
```