Skip to content

get_landsegs and get_riversegs to hydrotools (or cbp6_wsm?) #496

@rburghol

Description

@rburghol

R functions to extract these in R (mirrors the command line functions of the same name). @COBrogan

  • Function shown below for get_landsegs works but does not parse, only returns the whole text file. If we had an R regexp to parse these, that would be ideal.
    • This function is not yet added anywhere in hydrotools, it only exists in a vahydro river segment script.
    • River segments come back in exactly the same format, so the function that extracts a list or df of land segments would also work for river segments.
  • Running: get_landsegs("RU2_6090_6220",version="p6",instance="vadeq")
  • returns: set segments = ( H51079 H51113 L51079 N51079 N51113 )
basepath='/var/www/R';
source(paste(basepath,'config.R',sep='/'))
library('knitr')
library('dataRetrieval')

riverseg="RU2_6090_6220"
riverseg_feature <- RomFeature$new(ds,list(hydrocode=paste0('vahydrosw_wshed_',riverseg),bundle='watershed',ftype='vahydro'),TRUE)
riverseg_model <- riverseg_feature$get_prop(
  riverseg_feature$propvalues(propcode='vahydro-1.0')[1,]$propname
)
landseg='H51113'
landseg_feature <- RomFeature$new(ds,list(hydrocode=landseg,bundle='landunit',ftype='cbp6_landseg'),TRUE)
landseg_model <- landseg_feature$get_prop(propcode='cbp-6.1')
version='p6'
instance='vadeq'
get_landsegs <- function(riverseg,version, instance, site='http://deq1.bse.vt.edu:81') {
  uri=paste(site,version,instance,'config/seglists',paste0(riverseg,'.land'), sep='/')
  segs = httr::GET(uri, encode = "text")
  return(content(segs, as="text"))
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions