-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathScript_Run_RHESSysPreprocess.R
93 lines (79 loc) · 3.55 KB
/
Script_Run_RHESSysPreprocess.R
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
# run_RHESSysPreprocess
# Will Burke 3/5/18
# Last updated 4/20/19
# Instructions
# ------------
# This is an example script showing how the RHESSysPreprocess.R function should be run.
# 1) Install or source the RHESSysPreprocessing package
# 2) Copy this script, and edit where indicated.
# 3) Run the RHESSysPreprocess.R function at the bottom.
# 4) The funciton will produce:
# - worldfile
# - flowtable
# - optionally: header
# (metadata output is being worked on currently)
# Load Package
# ------------
# Assuming you installed the RHESSysPreprocessing package, you will need to load it
library(RHESSysPreprocessing)
# Filepaths
# ----------------
# This script uses relative filepaths. This means that it will look folders and files relative to your current working directory.
# If needed, set your current working directory to the folder of your project:
setwd("~/Documents/MyProject")
# This script also uses the "~", which is a shorthand method of navigating to your "home" user directory - typically the folder named for your username.
# Spatial Data
# ------------
# Set map_dir to the path of the folder containing your rasters
map_dir = "spatial_data"
# OLD deprecated: typepars = "spatial_data"
# Template
# --------
# The worldfile template is the key document that outlines how your worldfile will be built.
# The template variable should point to the name and location of your template.
template = "/templates/example.template"
# Name
# ----
# Set the name and path for all function outputs.
# Suffixes of .world, .flow, and .meta will be appended to the worldfile, flowtable, and metadata files respectively.
name = "/output/my_watershed"
# Overwrite
# ---------
# TRUE/FALSE if an existing worldfile and flowtable be overwritten.
overwrite = FALSE
# Streams
# -------
# Streams map to be used in creation of the flowtable - this is just the name of the map, to be found via the method indicated with "type"
streams = "my_watershed_streams"
# Optional Flowtable Spatial Data
# -------------------------------
# These maps are optional inputs in flowtable creation
# roads = "roads_map"
# impervious = "impervious_map"
# roofs = "roofs_map"
# Header
# ------
# TRUE/FALSE to produce a header file. Header file will be have same name(and location) set by "name", with the ".hdr" suffix.
header = FALSE
# Parallelization
# ---------------
# Current (Dec 2018 and on) develop branch RHESSys is hillslope paralleized and requires a flowtable that is compatible.
# Parallelization must be set to TRUE (this is a default)
# parallel = TRUE
# The "make_stream" argument defines the distance from an existing stream that the outlet of a hillslope can be set to be a
# stream.Since all hilslopes must have stream outlets, if a hillslope outlet exists outside of the distance threshold set by
# "make_stream",an error will occur and indicae the problem hillslope/outlet patch of that hillslope. This typically occurs
# as an artifact of how watershed analysis is done, and hillslopes are created, which sometimes results in fragmented or very
# small/skinny hillslopes, far away from streams.
# "make_stream" can be set to any positive value, or TRUE to always set hillslope outlets to streams.
# Default is 4, which is meant to roughly account for the errors/aritifacts that might occur from GIS, without including any
# extreme outlying hillslopes
# make_stream = 4
# Finally, run the function. Depending on size, it may take a minute or two.
RHESSysPreprocess(
template = template,
name = name,
map_dir = map_dir,
streams = streams,
overwrite = overwrite,
header = header)