Open rburghol opened 1 year ago
@megpritch See example method below for retrieving all rsegs (next step is to filter those down to just the sub-watersheds)
library("hydrotools")
basepath='/var/www/R';
source("/var/www/R/config.R")
##################################################################
# retrieve rsegs
##################################################################
# set up our data source environment
ds <- RomDataSource$new(site, rest_uname = rest_uname)
ds$get_token(rest_pw)
# retrieve all vahydro rseg features (this method is optimal b/c it allows retrieval of >100 records)
rsegs <- RomFeature$new(ds,list(ftype='vahydro',bundle='watershed'),TRUE)
# generate dataframe of rseg hydrocodes
rsegs_hydrocode_df <- data.frame("hydrocode"=character(),stringsAsFactors=FALSE)
for (i in 1:length(rsegs$hydrocode)){
rsegs_hydrocode_df <- rbind(rsegs_hydrocode_df,rsegs$hydrocode[i])
}
print(head(rsegs_hydrocode_df))
##################################################################
##################################################################
# Next, use sqldf to query the sub-watersheds within the dataframe
# of hydrocodes (those with hydrocode greater than 29 characters)
##################################################################
# sqldf() here
##################################################################
Revised:
rsegs <- RomFeature$new(ds,list(ftype='vahydro',bundle='watershed'),TRUE)
subshed<- subset(rsegs$hydrocode, nchar(rsegs$hydrocode)>29)
subshed <- data.frame(subshed)
Create batch script to create all subshed ftables :
ftable_creation.R
#331 to call to create a new FTABLE with arguments describing province, DA, and maybe lat/lon? (also river segment name of course), destination folder, model version (cbp-5.3.2 or cbp-6.0)