Skip to content

Commit bcb15e1

Browse files
committed
added examples and started vignette
1 parent e369a97 commit bcb15e1

4 files changed

Lines changed: 87 additions & 19 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
.Rhistory
33
.RData
44
.Ruserdata
5+
Example_Data/NHDPlus/

Example_Data/Sample_Locations.csv

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
SiteName,StreamName,N,W,VPU
2-
SC2,Sycamore Creek,33.86396,-111.4655,15
3-
SC3,Sycamore Creek,33.78711,-111.50788,15
4-
WC1,Workman Creek,33.83373,-110.95091,15
5-
WC2,Workman Creek,33.84628,-110.9681,15
6-
WC3,Workman Creek,33.84776,-110.98302,15
72
CC2,Carrizo Creek,37.16442,-103.03109,11
83
CC3,Carrizo Creek,37.13483,-103.01728,11
94
MC1,Jimmy Creek,34.81536,-98.58271,11
@@ -12,7 +7,3 @@ MC3,Medicine Creek,34.77091,-98.58141,11
127
KR1,Upper Kiamichi River,34.67789,-94.46922,11
138
KR2,Upper Kiamichi River,34.67746,-94.48624,11
149
KR3,Upper Kiamichi River,34.66721,-94.535,11
15-
SS1,Troublesome Branch,32.9778,-87.4146,03W
16-
SS2,Mayfield Creek,32.9683,-87.408,03W
17-
SS3,South Sandy Creek,32.9661,-87.3919,03W
18-
TC,Terlingua Creek,29.20012,-103.60625,13
Lines changed: 86 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,102 @@
11
# example workflow for StreamNetworkTools
2-
remove.packages("StreamNetworkTools")
32

43
# install devtools if not already
5-
#install.packages(devtools)
4+
# install.packages(devtools)
65
library("devtools")
7-
#install StreamNetworkTools from github repository
8-
#install_git("https://github.com/dkopp3/StreamNetworkTools_git.git", subdir = "StreamNetworkTools")
6+
7+
# install StreamNetworkTools from github repository
8+
# install_git("https://github.com/dkopp3/StreamNetworkTools_git.git", subdir = "StreamNetworkTools")
99
library(StreamNetworkTools)
1010

11-
#check package help
12-
help(package="StreamNetworkTools")
11+
#check SNT package help for avaialble functions
12+
help(package ="StreamNetworkTools")
1313

1414
# to begin download NHDPlusV2 data for Vector Processing Unit (VPU) of interest
1515
# here we are using VPU 11 which includes Arkansas, Red and White River basins
1616
# check function documentation for further details
1717
# setwd to example folder - where NHDPlusV2 data will be downloaded
18-
# this is mostly to keep myself organized
18+
1919
setwd("C:/Users/Darin/Dropbox/Dissertation/Chapter_2_StreamNetworkTools/StreamNetworkTools_git/Example_Data")
2020

21-
?net_nhdplus
22-
net_nhdplus(nhdplus_path = getwd(), download = "http",
23-
vpu = 11, files = ALL, zip_7 = "C:/Program Files/7-Zip")
21+
# check documentation
22+
# net_nhdplus
23+
# can download all available data for vpu but sppecified only files needed to run streamNetworkTools
24+
# this can be time consuming, be patient it only has to be done once
25+
# data for VPU is already present in example data folder
26+
27+
#net_nhdplus(nhdplus_path = getwd(), download = "http",
28+
# vpu = 11, files = c("NHDPlusAttributes", "NHDSnapshot",
29+
# "NHDPlusCatchment", "VPUAttributeExtension",
30+
# "VogelExtension", "EROMExtension"),
31+
# zip_7 = "C:/Program Files/7-Zip")
32+
33+
# can run with for loop to download all VPU in CONUS
34+
# recommend running overnight
35+
36+
#vpus<- c("01","02","03N","03S","03W","04","05","06","07","08","09","10U",
37+
# "10L","11","12","13","14","15","16","17","18")
38+
39+
# for (i in vpus){
40+
# net_nhdplus(nhdplus_path = getwd(), download = "http",
41+
# vpu = i, files = c("NHDPlusAttributes", "NHDSnapshot",
42+
# "NHDPlusCatchment", "VPUAttributeExtension",
43+
# "VogelExtension", "EROMExtension"),
44+
# zip_7 = "C:/Program Files/7-Zip")
45+
#}
46+
47+
# net_sample randomly selects comid's of specified stream order from a vector processing unit
48+
# below identifies 3, fifth order comid's from VPU 11
49+
50+
rmd_comid <- net_sample(nhdplus_path = getwd(), vpu = "11", ws_order = 5, n = 3)
51+
print(rmd_comid)
52+
53+
# net_delin queries all COMID's upsteam comid's from root
54+
# inpput group_comids must be character
55+
rmd_netdelin <- net_delin(group_comid = as.character(rmd_comid),
56+
nhdplus_path = getwd(),
57+
vpu = "11")
58+
# output is list of 3
59+
str(rmd_netdelin)
60+
61+
# can write network as shapefile with
62+
library(sf)
63+
write_sf(rmd_netdelin$SF_Obj, paste(getwd(),"/rmd_netdelin.shp", sep = ""))
64+
65+
# value added attribute queries for NHDPlusV2
66+
# landcover percentage are for sub-catchments
67+
rmd_netlc <- net_lc(netdelin = rmd_netdelin, vpu = "11", nhdplus_path = getwd())
68+
# field headings follow https://www.mrlc.gov/nlcd11_leg.php
69+
head(rmd_netlc)
70+
71+
# climate variables follow world clim, bioclim variables and were calculated from 1971-2001 PRISM
72+
# where necessary units are in tempp in deg C and ppt in mm
73+
rmd_netclim <- net_clim (nhdplus_path = getwd(), vpu = "11", netdelin = rmd_netdelin)
74+
head(rmd_netclim)
75+
76+
# flow variables were calculated using the Mean Annual and Mean Monthly EROM
77+
rmd_netflow <- net_flow(nhdplus_path = getwd(), vpu = "11", netdelin = rmd_netdelin)
78+
head(rmd_netflow)
79+
80+
# network scale topology
81+
rmd_netclac <- net_calc(netdelin = rmd_netdelin, vpu = "11", nhdplus_path = getwd())
82+
head(rmd_netclac)
83+
84+
# net_hort M values are not included here
85+
rmd_nethort <- net_hort(netdelin = rmd_netdelin, vpu = "11", nhdplus_path = getwd())
86+
str(rmd_nethort)
2487

88+
# net sinu gives values for each reach (comid) within a network
89+
rmd_netsinu <- net_sinu (netdelin = rmd_netdelin, nhdplus_path = getwd(), vpu = "11")
90+
head(rmd_netsinu)
2591

92+
# can be aggregated as a network mean
93+
mean.sinu <- aggregate(rmd_netsinu[,"sinuosity"],
94+
by = list(group.comid = rmd_netsinu[,"group.comid"]),
95+
mean)
96+
head(mean.sinu)
2697

98+
# net_conflu resullts are given by each confluence
99+
# this takes a while - ended
100+
#rmd_netconflu <- net_conflu(netdelin = rmd_netdelin,
101+
# nhdplus_path = getwd(),
102+
# vpu = "11")
4.88 KB
Binary file not shown.

0 commit comments

Comments
 (0)