Package 'RRASSLER'

Title: R based HEC-RAS model accounting wrestler
Description: A package for making HEC-RAS data more FAIR by cataloging models, cross sections, and points for accounting, interoperability, and reuse in RAS and other applications. These tools are experimental, preliminary or provisional and are subject to revision. They are being provided to meet the need for timely better science and emergency response.
Authors: Jim Coll [aut, cre] , Mike Johnson [ctb] , Laura Keys [ctb] , Andy Carter [ctb, trl], NOAA [fnd], Lynker [fnd]
Maintainer: Jim Coll <[email protected]>
License: MIT + file LICENSE
Version: 0.1.1
Built: 2024-12-06 21:24:03 UTC
Source: https://github.com/NOAA-OWP/RRASSLER

Help Index


append_catalog_fields

Description

adds helper fields to accounting.csv.

Usage

append_catalog_fields(
  path_to_ras_dbase = NULL,
  out_name = NULL,
  overwrite = FALSE,
  is_verbose = TRUE,
  HUC8_override = NULL
)

Arguments

path_to_ras_dbase

the path to the folder in which you are building your catalog, Default: NULL

out_name

the name of the csv you want to generate, Default: NULL

overwrite

flag to dictate whether or not to overwrite the out_name, should it exist. set to TRUE to delete and (re)generate, FALSE to safely exit, Default: FALSE

is_verbose

flag to determine whether print statements are suppressed, TRUE to show messages and FALSE to surpress them, Default: TRUE

HUC8_override

a path to the spatial key if you need to run this over a temp dir for eg ras2fim, Default: NULL

Details

TRUE

Value

a new csv with helper columns

See Also

glue mutate s2, st_transform, st_read, st_crs fwrite

Other post-process: refresh_master_files()

Examples

## Not run: 
if(interactive()){
 #EXAMPLE
 RRASSLER::append_catalog_fields(path_to_ras_dbase = "G:/data/ras_catalog",out_name = "OWP_ras_model_catalog.csv",overwrite = FALSE,is_verbose = TRUE)
 }

## End(Not run)

cloud_ingest_record

Description

Depreciated - add a file as a record in the RRASSLED structure - Depreciated

Usage

cloud_ingest_record(
  in_file = NULL,
  ras_dbase = NULL,
  root_bucket = NULL,
  code_to_place_in_source = NULL,
  proj_override = NULL,
  apply_vdat_trans = FALSE,
  is_quiet = FALSE,
  is_verbose = FALSE,
  overwrite = FALSE
)

Arguments

in_file

the path to the file on disk that we want to ingest, Default: NULL

ras_dbase

A path to an S3 bucket to write your RRASSLED catalog to., Default: NULL

root_bucket

first path in s3 url, will auto-populate as needed, Default: NULL

code_to_place_in_source

a code to place in the metadata as the owner of the model, Default: NULL

proj_override

a string to override projection information should none be found, Default: NULL

apply_vdat_trans

Should VDATUM be applied to the HEC-RAS model geometry. See https://vdatum.noaa.gov/, Default: FALSE

is_quiet

flag to determine whether print statements are suppressed, TRUE to suppress messages and FALSE to show them, Default: FALSE

is_verbose

flag to determine whether internal print statements (i.e. cross section parsing, vdat trans, file info) are suppressed, TRUE to show these messages and FALSE to suppress them, Default: FALSE

overwrite

overwrite files if we find identical models, Default: FALSE

Details

the cloud version of the ingest process, depreciated in favor of local pre-RRASSL

Value

a set of files in a newly RRASSLE'd record.

See Also

str_sub, str_detect get_bucket, delete_object, put_object glue glob2rx st_crs, st_coordinates, geos_unary, st_write select, pull data.table-package, fwrite sf_linestring, sf_polygon st_startpoint get_nhdplus aoi_get write_parquet

Other ingest: disk_ingest_record(), ingest_FEMA6_BLE(), ingest_into_database()

Examples

## Not run: 
if(interactive()){
 #EXAMPLE1
 }

## End(Not run)

crosswalk_hull_to_hydrofabric_value

Description

crosswalk_hull_to_hydrofabric_value

Usage

crosswalk_hull_to_hydrofabric_value(hull, river)

Arguments

hull

the model cross section hulls

river

the river streamlines

Details

Used to tie into hydrofabric models

Value

The representative COMID from nhdplusTools

See Also

get_nhdplus aoi_get st_transform, st_crs

Examples

## Not run: 
if(interactive()){
 #EXAMPLE1
 extrated_pts <- parse_model_to_xyz(geom_path = "./inst/extdata/sample_ras/FEMA-R6-BLE-sample-dataset/12090301/12090301_models/Model/Alum Creek-Colorado River/ALUM 006/ALUM 006.g01",units = "English Units",proj_string = "EPSG:2277",vdat_trans = FALSE,quiet = FALSE)

 ls = sfheaders::sf_linestring(
   obj = extrated_pts[[1]],
   x = "x",
   y = "y",
   linestring_id = "xid",
   keep = FALSE) |> sf::st_set_crs(sf::st_crs("EPSG:6349"))
 ls_final_line_index <- nrow(ls)
 ls_end_index <- nrow(ls)-1
 ls_middle_lines_end <- ls[2:ls_end_index,] |> lwgeom::st_endpoint()
 ls_middle_lines_start <- ls[2:ls_end_index,] %>% lwgeom::st_startpoint()

 df_hull_pts <- rbind(
   sf::st_coordinates(ls[1,]$geometry)[, -c(3)],
   sf::st_coordinates(ls_middle_lines_end),
   apply(sf::st_coordinates(ls[ls_final_line_index,]$geometry)[, -c(3)], 2, rev),
   apply(sf::st_coordinates(ls_middle_lines_start), 2, rev))
 hull = sfheaders::sf_polygon(
   obj = df_hull_pts,
   x = "X",
   y = "Y",
   keep = FALSE) |> sf::st_set_crs(sf::st_crs("EPSG:6349"))

 river <- extrated_pts[[3]]
 current_nhdplus_comid <- crosswalk_hull_to_hydrofabric_value(hull,river)
 }

## End(Not run)

disk_ingest_record

Description

add a file as a record in the RRASSLED structure

Usage

disk_ingest_record(
  in_file = NULL,
  path_to_ras_dbase = NULL,
  code_to_place_in_source = NULL,
  proj_override = NULL,
  apply_vdat_trans = FALSE,
  is_quiet = FALSE,
  is_verbose = FALSE,
  overwrite = FALSE
)

Arguments

in_file

the path to the file on disk that we want to ingest, Default: NULL

code_to_place_in_source

a code to place in the metadata as the owner of the model, Default: NULL

proj_override

a string to override projection information should none be found, Default: NULL

apply_vdat_trans

Should VDATUM be applied to the HEC-RAS model geometry. See https://vdatum.noaa.gov/, Default: FALSE

is_quiet

flag to determine whether print statements are suppressed, TRUE to suppress messages and FALSE to show them, Default: FALSE

is_verbose

flag to determine whether internal print statements (i.e. cross section parsing, vdat trans, file info) are suppressed, TRUE to show these messages and FALSE to suppress them, Default: FALSE

overwrite

overwrite files if we find identical models, Default: FALSE

ras_dbase

A path to a directory to write your RRASSLED catalog to., Default: NULL

Details

the disk version of the ingest process

Value

a set of files in a newly RRASSLE'd record.

See Also

glob2rx glue st_crs, st_coordinates, st_write str_sub, str_detect data.table-package, fwrite sf_linestring, sf_polygon st_startpoint write_parquet

Other ingest: cloud_ingest_record(), ingest_FEMA6_BLE(), ingest_into_database()

Examples

## Not run: 
if(interactive()){
 #EXAMPLE1
 # ras_dbase <- "./inst/extdata/sample_output/ras_catalog/"
 # dir_to_scrape <- "./inst/extdata/sample_ras/FEMA-R6-BLE-sample-dataset/"
 dir_to_scrape <- fs::path_package("extdata/shapes.fgb", package = "mypkg")
 list_of_prj_files <- list.files(dir_to_scrape,pattern = glob2rx("*.prj$"),full.names = TRUE,ignore.case = TRUE,recursive = TRUE)
 disk_ingest_record(in_file = list_of_prj_files[1], path_to_ras_dbase = ras_dbase,code_to_place_in_source = "test",proj_override = "EPSG:2277",apply_vdat_trans = FALSE,is_quiet = FALSE,is_verbose = FALSE,overwrite = FALSE)

 #EXAMPLE2
 dir_to_scrape <- "./inst/extdata/sample_ras/ras2fim-sample-dataset/"
 list_of_prj_files <- list.files(dir_to_scrape,pattern = glob2rx("*.prj$"),full.names = TRUE,ignore.case = TRUE,recursive = TRUE)
 disk_ingest_record(in_file = list_of_prj_files[1], path_to_ras_dbase = ras_dbase,code_to_place_in_source = "test",proj_override = "EPSG:26915",apply_vdat_trans = FALSE,is_quiet = FALSE,is_verbose = TRUE,overwrite = FALSE)
 }

## End(Not run)

get_datum_from_crs

Description

attempts to parse datum and datum unit from file based on WKT

Usage

get_datum_from_crs(x)

Arguments

x

either the string or the sf crs

Details

DETAILS

Value

list of CRS and vertical unit

See Also

[st_crs][sf::st_crs]

Examples

## Not run: 
if(interactive()){
 #EXAMPLE1
 get_datum_from_crs("EPSG:6349")

 EXAMPLE2
 get_datum_from_crs(sf::st_crs("EPSG:6349"))

 }

## End(Not run)

ingest_FEMA6_BLE

Description

helper to ingest FEMA region 6 BLE data

Usage

ingest_FEMA6_BLE(
  path_to_ras_dbase,
  HUCID,
  proj_override = NULL,
  apply_vdat_trans = FALSE,
  is_quiet = FALSE,
  is_verbose = TRUE,
  overwrite = FALSE,
  parallel_proc = TRUE,
  free_treads = 2,
  clean = FALSE,
  opt_local_path = NULL
)

Arguments

path_to_ras_dbase

The path to the folder in which you are building your catalog, Default: NULL

HUCID

string to huc8

proj_override

a CRS string to apply should a projection not be found, Default: NULL

apply_vdat_trans

a flag to dictate whether or not to apply a vdatum transformation, TRUE to apply, FALSE to skip, Default: FALSE

is_quiet

flag to determine whether print statements are suppressed, TRUE to suppress messages and FALSE to show them, Default: FALSE

is_verbose

flag to determine whether internal print statements (i.e. cross section parsing, vdat trans, file info) are suppressed, TRUE to show these messages and FALSE to suppress them, Default: TRUE

overwrite

overwrite files if we find identical models, Default: FALSE

parallel_proc

Flag to determine if this should this parallel process, will check for enough free cores and boot this back if it exceeds available resources. Will suppress all intermediate messages if active, Default: TRUE

free_treads

number of threads to leave free if parallel processing, Default: 2

clean

number of threads to leave free if parallel processing, Default: 2

opt_local_path

PARAM_DESCRIPTION, Default: NULL

Details

As one of the best centralized and accessible databases, the FEMA region 6 BLE data are perfect candidates to RRASSL. This provides a wrapper around BLE scrapers and the ingest_into_database function.

Value

a RRASSLE'd catalog of models or added desired HUC8 models

See Also

str_sub glue unzip st_read, st_crs

Other ingest: cloud_ingest_record(), disk_ingest_record(), ingest_into_database()

Examples

## Not run: 
if(interactive()){
 #EXAMPLE1
 RRASSLER::ingest_FEMA6_BLE(path_to_ras_dbase = "G:/data/ras_catalog/","12090301",proj_override = "EPSG:2277",apply_vdat_trans = FALSE,is_quiet = FALSE,is_verbose = FALSE,overwrite = FALSE,parallel_proc = TRUE,free_treads = 2)
 }

## End(Not run)

ingest_into_database

Description

ingest files from a source directory on your drive into a formatted input directory

Usage

ingest_into_database(
  path_to_ras_dbase,
  top_of_dir_to_scrape,
  code_to_place_in_source,
  proj_override = NULL,
  apply_vdat_trans = FALSE,
  is_quiet = FALSE,
  is_verbose = FALSE,
  overwrite = FALSE,
  parallel_proc = TRUE,
  free_treads = 2
)

Arguments

path_to_ras_dbase

A path to a directory to write your RRASSLED directory to. See Methods and Structures for more details. is location agnostic so this can be either a local path or an s3 bucket

top_of_dir_to_scrape

The top of the directory to look for models. Will greedy search and find all models as described in Ingest logic

code_to_place_in_source

a string to place into the model source column. Useful to distinguish data authors

proj_override

a string to override projection information should none be found, Default: NULL

apply_vdat_trans

Should VDATUM be applied to the HEC-RAS model geometry. See https://vdatum.noaa.gov/, Default: FALSE

is_quiet

flag to determine whether print statements are suppressed, TRUE to suppress messages and FALSE to show them, Default: FALSE

is_verbose

flag to determine whether internal print statements (i.e. cross section parsing, vdat trans, file info) are suppressed, TRUE to show these messages and FALSE to suppress them, Default: FALSE

overwrite

overwrite files if we find identical models, Default: FALSE

parallel_proc

Flag to determine if this should this parallel process, will check for enough free cores and boot this back if it exceeds available resources. Will suppress all intermediate messages if active, Default: TRUE

free_treads

number of threads to leave free if parallel processing, Default: 2

Details

here 'ingest' means add to our accounting system and database refers to our folder structure

Value

a RRASSLE'd catalog of models

See Also

glue str_sub detectCores, makeCluster registerDoParallel foreach

Other ingest: cloud_ingest_record(), disk_ingest_record(), ingest_FEMA6_BLE()

Examples

## Not run: 
if(interactive()){
 #EXAMPLE1
 # ras_dbase <- file.path("~/data/ras_catalog/")
 ras_dbase <- file.path("./inst/extdata/sample_output/ras_catalog/")

 dir_to_scrape <- "./inst/extdata/sample_ras/FEMA-R6-BLE-sample-dataset/"
 RRASSLER::ingest_into_database(path_to_ras_dbase = ras_dbase,top_of_dir_to_scrape = dir_to_scrape,code_to_place_in_source = "test: FEMA6",proj_override = "EPSG:2277",apply_vdat_trans = FALSE,is_quiet = FALSE,is_verbose = TRUE,overwrite = FALSE,parallel_proc = FALSE)

 dir_to_scrape <- "./inst/extdata/sample_ras/ras2fim-sample-dataset/input_iowa/"
 RRASSLER::ingest_into_database(path_to_ras_dbase = ras_dbase,top_of_dir_to_scrape = dir_to_scrape,code_to_place_in_source = "test: Iowa input",proj_override = "EPSG:26915",apply_vdat_trans = FALSE,is_quiet = FALSE,is_verbose = TRUE,overwrite = FALSE,parallel_proc = FALSE)

 dir_to_scrape <- "./inst/extdata/sample_ras/ras2fim-sample-dataset/output_iowa/"
 RRASSLER::ingest_into_database(path_to_ras_dbase = ras_dbase,top_of_dir_to_scrape = dir_to_scrape,code_to_place_in_source = "test: RAS2FIM V1",proj_override = "EPSG:26915",apply_vdat_trans = FALSE,is_quiet = FALSE,is_verbose = TRUE,overwrite = FALSE,parallel_proc = FALSE)

 # Sys.setenv("AWS_ACCESS_KEY_ID" = "AKIASUPERSECRET","AWS_SECRET_ACCESS_KEY" = "evenmoresecret","AWS_DEFAULT_REGION" = "us-also-secret")
 dir_to_scrape <- "./inst/extdata/sample_ras/FEMA-R6-BLE-sample-dataset/"
 RRASSLER::ingest_into_database(path_to_ras_dbase = "s3://ras-models/",top_of_dir_to_scrape = dir_to_scrape,code_to_place_in_source = "test: FEMA6",proj_override = "EPSG:2277",apply_vdat_trans = FALSE,is_quiet = FALSE,is_verbose = TRUE,overwrite = FALSE,parallel_proc = FALSE)
 }

## End(Not run)

load_catalog_csv_as_DT

Description

Helper to ensure catalog edge cases and incorrect formats are correctly handled (most commonly numeric strings parsed into characters)

Usage

load_catalog_csv_as_DT(path_to_csv, is_quiet = TRUE)

Arguments

path_to_csv

path to the model_catalog.csv file under your catalog folder

is_quiet

if TRUE, function will suppress message, Default: TRUE

Details

a little utility that sets column types on load for some of our sillier edge cases. the vector applied is 'data.table::fread(path_to_csv,colClasses = c("nhdplus_comid" = "character","model_name" = "character","units" = "character","crs" = "character","final_name_key" = "character"))'

Value

returns the model_catalog as a data.table object with enforced column types

See Also

fread

Other helper: marco(), print_error_block(), print_warning_block(), url_exists(), util_unzip()

Examples

## Not run: 
if(interactive()){
 #EXAMPLE1
 ras_catalog_dbase = load_catalog_csv_as_DT(file.path(path_to_ras_dbase, "accounting.csv", fsep = .Platform$file.sep),is_quiet = !is_verbose)
 }

## End(Not run)

make_xs_hyfab_comp

Description

FUNCTION_DESCRIPTION

Usage

make_xs_hyfab_comp(
  path_to_ras_dbase = NULL,
  line_select_subset = NULL,
  hf_lines,
  overwrite = FALSE,
  is_verbose = TRUE
)

Arguments

path_to_ras_dbase

PARAM_DESCRIPTION, Default: NULL

line_select_subset

PARAM_DESCRIPTION, Default: NULL

hf_lines

PARAM_DESCRIPTION

overwrite

PARAM_DESCRIPTION, Default: FALSE

is_verbose

PARAM_DESCRIPTION, Default: TRUE

Details

DETAILS

Value

OUTPUT_DESCRIPTION

See Also

glue st_read, st_transform, st_crs, sf, sfc, geos_binary_ops, geos_unary, st_cast, geos_measures, st_as_sf, st_write read_parquet, write_parquet units mutate, group_by, summarise

Examples

## Not run: 
if(interactive()){
 #EXAMPLE1
 make_xs_hyfab_comp(path_to_ras_dbase = NULL,line_select_subset = NULL,hf_lines,overwrite = FALSE,is_verbose = TRUE)
 }

## End(Not run)

map_library

Description

a function to help apply geographic context to the RRASSLED catalog

Usage

map_library(
  path_to_ras_dbase,
  AOI_to_map = NULL,
  name = "model_map",
  plot_lines = FALSE,
  chart_lines = FALSE,
  refresh = FALSE,
  quiet = TRUE
)

Arguments

path_to_ras_dbase

The path to the folder in which you are building your catalog, Default: NULL

AOI_to_map

An AOI pass though to subset the catalog down into a smaller area to add the context too, Default: NULL

name

A name for the map files to create, Default: 'model_map'

plot_lines

draw lines on the map as opposed to just the footprints, Default: FALSE

chart_lines

Add cross section click graphs to the plot lines. Will break if area is too large, Default: FALSE

refresh

flag to dictate whether or not to recollate spatial database prior to mapping. FALSE to skip, TRUE to regenerate, Default: TRUE

quiet

flag to determine whether print statements are suppressed, TRUE to suppress messages and FALSE to show them, Default: FALSE

Details

DETAILS

Value

OUTPUT_DESCRIPTION

See Also

st_transform, st_read, st_crs, valid read_parquet ggplot, aes, geom_point, ggtheme, scale_colour_gradient, labs leaflet, addProviderTiles, addLegend, addLayersControl addFeatures popupGraph glue mapshot

Examples

## Not run: 
if(interactive()){
 #EXAMPLE
 RRASSLER::map_library(path_to_ras_dbase = cat_path,NULL,name = "model_map",plot_lines = TRUE,chart_lines = TRUE,refresh = FALSE,quiet = FALSE)
 }

## End(Not run)

Hello world

Description

A hello world tester

Usage

marco()

Details

Used to verify that RRASSLER is successfully loaded and test deployment pathways. Copy-paste-d and not drawn from Google (https://www.asciiart.eu/art-and-design/sculptures)

Value

a hello world message (polo!)

See Also

Other helper: load_catalog_csv_as_DT(), print_error_block(), print_warning_block(), url_exists(), util_unzip()

Examples

RRASSLER::marco()

parse_model_to_xyz

Description

parse a model into an xyz dataframe from basename, considers both g## and g##.hdf files

Usage

parse_model_to_xyz(
  geom_path,
  units,
  proj_string,
  in_epoch_override = as.integer(as.POSIXct(Sys.time())),
  out_epoch_override = as.integer(as.POSIXct(Sys.time())),
  vdat_trans = FALSE,
  quiet = FALSE,
  is_verbose = TRUE
)

Arguments

geom_path

path to the base model

units

units found in the project, "English Units" or "SI Units"

proj_string

PARAM_DESCRIPTION

in_epoch_override

PARAM_DESCRIPTION, Default: as.integer(as.POSIXct(Sys.time()))

out_epoch_override

PARAM_DESCRIPTION, Default: as.integer(as.POSIXct(Sys.time()))

vdat_trans

PARAM_DESCRIPTION, Default: FALSE

quiet

flag to determine whether print statements are suppressed, TRUE to suppress messages and FALSE to show them, Default: FALSE

is_verbose

flag to determine whether internal print statements (i.e. cross section parsing, vdat trans, file info) are suppressed, TRUE to show these messages and FALSE to suppress them, Default: TRUE

Details

DETAILS

Value

OUTPUT_DESCRIPTION

See Also

str_sub unglue

Examples

## Not run: 
if(interactive()){
 #EXAMPLE1
 # g_path <- "./inst/extdata/sample_ras/FEMA-R6-BLE-sample-dataset/12090301/12090301_models/Model/Alum Creek-Colorado River/ALUM 006/ALUM 006.g01"
 g_path <- fs::path_package("extdata/shapes.fgb", package = "mypkg")
 pts <- parse_model_to_xyz(geom_path = g_path,units = "English Units",proj_string = "EPSG:2277",quiet = FALSE)

 g_path <- "./inst/extdata/sample_ras/ras2fim-sample-dataset/input_iowa/10170204000897/Hydraulic_Models/Simulations/10170204000897.g01"
 pts <- parse_model_to_xyz(geom_path = g_path,units = "SI Units",proj_string = "EPSG:26915",quiet = FALSE)

 select_model_index <- 120
 target_model <- ras_catalog[select_model_index,]
 pts <- parse_model_to_xyz(geom_path = file.path(ras_dbase,"models",target_model$final_name_key,glue::glue("{target_model$model_name}.{target_model$g_file}"),fsep = .Platform$file.sep),
 units = target_model$units,
 proj_string = target_model$crs,
 quiet = FALSE,is_verbose = TRUE)
 }

## End(Not run)

process_ras_g_to_xyz

Description

process a ras g file into xyz format

Usage

process_ras_g_to_xyz(
  geom_path,
  units,
  proj_string,
  in_epoch_override = as.integer(as.POSIXct(Sys.time())),
  out_epoch_override = as.integer(as.POSIXct(Sys.time())),
  vdat = FALSE,
  quiet = FALSE
)

Arguments

geom_path

path to a file to parse

units

units found in the project, "English Units" or "SI Units"

proj_string

a projection string to apply

in_epoch_override

vdatum parameter input epoch, Default: as.integer(as.POSIXct(Sys.time()))

out_epoch_override

vdatum parameter output epoch, Default: as.integer(as.POSIXct(Sys.time()))

vdat

a flag to dictate whether or not to apply a vdatum transformation, TRUE to apply, FALSE to skip, Default: FALSE, Default: FALSE

quiet

flag to determine whether print statements are suppressed, TRUE to suppress messages and FALSE to show them, Default: FALSE

Details

DETAILS

Value

a point database and notes about processing

See Also

glob2rx, read.table glue as.data.table str_split, str_trim, str_flatten, str_sub sf_linestring sf, st_cast, st_crs, st_read, st_transform, st_coordinates, st_as_sf, geos_measures fill decimal_date, ymd GET, http_error, content st_linesubstring, st_startpoint

Examples

## Not run: 
if(interactive()){
 #EXAMPLE1
 # g_path <- "./inst/extdata/sample_ras/FEMA-R6-BLE-sample-dataset/12090301/12090301_models/Model/Alum Creek-Colorado River/ALUM 006/ALUM 006.g01"
 pts <- process_ras_g_to_xyz(geom_path = g_path,units = "English Units",proj_string = "EPSG:2277",vdat = FALSE,quiet = FALSE)
 }

## End(Not run)

process_ras_hdf_to_xyz

Description

process a ras g##.hdf file into xyz format

Usage

process_ras_hdf_to_xyz(
  geom_path,
  units,
  proj_string,
  in_epoch_override = as.integer(as.POSIXct(Sys.time())),
  out_epoch_override = as.integer(as.POSIXct(Sys.time())),
  vdat = FALSE,
  quiet = FALSE
)

Arguments

geom_path

path to a file to parse

units

units found in the project, "English Units" or "SI Units"

proj_string

a projection string to apply

in_epoch_override

vdatum parameter input epoch, Default: as.integer(as.POSIXct(Sys.time()))

out_epoch_override

vdatum parameter output epoch, Default: as.integer(as.POSIXct(Sys.time()))

vdat

a flag to dictate whether or not to apply a vdatum transformation, TRUE to apply, FALSE to skip, Default: FALSE

quiet

flag to determine whether print statements are suppressed, TRUE to suppress messages and FALSE to show them, Default: FALSE

Details

DETAILS

Value

a point database and notes about processing

See Also

[str_detect][stringr::str_detect] [stri_sub][stringi::stri_sub] [h5read][rhdf5::h5read] [sf_linestring][sfheaders::sf_linestring] [st_sf][sf::st_sf], [st_cast][sf::st_cast], [st_crs][sf::st_crs], [st_transform][sf::st_transform], [st_coordinates][sf::st_coordinates], [st_as_sf][sf::st_as_sf], [st_set_crs][sf::st_set_crs], [st_length][sf::st_length] [decimal_date][lubridate::decimal_date], [ymd][lubridate::ymd] [GET][httr::GET], [http_error][httr::http_error], [content][httr::content] [fill][tidyr::fill] [st_linesubstring][lwgeom::st_linesubstring], [st_endpoint][lwgeom::st_endpoint] [glue][glue::glue]

Examples

## Not run: 
if(interactive()){
 #EXAMPLE1
 # ghdf_path <- "./inst/extdata/sample_ras/FEMA-R6-BLE-sample-dataset/12090301/12090301_models/Model/Alum Creek-Colorado River/ALUM 006/ALUM 006.g01.hdf"
 ghdf_path <- fs::path_package("extdata/shapes.fgb", package = "mypkg")
 pts <- process_ras_hdf_to_xyz(geom_path = ghdf_path,units = "English Units",proj_string = "EPSG:2277",vdat = FALSE,quiet = FALSE)
 }

## End(Not run)

refresh_master_files

Description

remerge individual files into spatial model key

Usage

refresh_master_files(path_to_ras_dbase, is_verbose = TRUE, overwrite = TRUE)

Arguments

path_to_ras_dbase

The path to the folder in which you are building your catalog, is also location agnostic (disk or cloud), Default: NULL

is_verbose

flag to determine whether print statements are shown - TRUE to show messages - FALSE to skip non-critical ones, Default: TRUE

overwrite

flag to determine whether the catalog is either overwritten (overwrite = TRUE), or a duplicated catalog is copied and appended with the date (overwrite = FALSE) as requested [here](https://github.com/NOAA-OWP/RRASSLER/issues/6), Default: TRUE

Details

TRUE

Value

updated master index files including accounting.csv, point_database.parque, XS.fgb, and model_footprints.fgb

See Also

str_sub get_bucket, get_object, delete_object, put_object as.data.table, fwrite, rbindlist read_delim glob2rx glue st_read, st_crs, st_write read_parquet, write_parquet sf_linestring

Other post-process: append_catalog_fields()

Examples

## Not run: 
if(interactive()){
 # ras_dbase <- file.path("~/data/ras_catalog/")
 ras_dbase <- file.path("./inst/extdata/sample_output/ras_catalog/")

 RRASSLER::refresh_master_files(path_to_ras_dbase = ras_dbase,is_verbose = TRUE)

 RRASSLER::refresh_master_files(path_to_ras_dbase = "s3://ras-models/",is_verbose = TRUE, overwrite = FALSE)
 }

## End(Not run)

FEMA region 6 BLE data scraper

Description

Helper to download relevant BLE data

Usage

scrape_ble_lib(
  database_path,
  HUCID,
  is_quiet = FALSE,
  overwrite = overwrite,
  files = "m"
)

Arguments

database_path

Path to load data into. NOTE: Must be LOCAL path

HUCID

The huc8 ID as a string to try and scrape

is_quiet

flag to determine whether print statements are suppressed, TRUE to suppress messages and FALSE to show them, Default: FALSE

overwrite

overwrite flag for data already loaded in your path. TRUE to remove and re-download., Default: overwrite

files

a string encoding to determine what files to attempt to download, can contain 'm' for models, 's' for spatial data, and 'd' for documentation, Default: 'm'

Details

Scraping data from https://ebfedata.s3.amazonaws.com/ based on pointers from https://webapps.usgs.gov/infrm/estBFE/. See also the Texas specific dashboard at https://www.arcgis.com/apps/dashboards/1e98f1e511fc40d3b08790a4251a64ee for more BLE base models.

Value

The requested BLE data as a scraped zip file

See Also

st_transform, st_read, st_crs GET, write_disk glue

Examples

## Not run: 
if(interactive()){
 #EXAMPLE1
 database_path <- file.path("~/data/ras_catalog/")
 RRASSLER::scrape_ble_lib(database_path,'12090301',is_quiet = FALSE,overwrite = FALSE,files = "ms")
 }

## End(Not run)

URL tester

Description

A function to test if I get a response from a URL

Usage

url_exists(x, non_2xx_return_value = FALSE, is_quiet = FALSE)

Arguments

x

the URL to test

non_2xx_return_value

PARAM_DESCRIPTION, Default: FALSE

is_quiet

flag to determine whether print statements are suppressed, TRUE to suppress messages and FALSE to show them, Default: FALSE

Details

gratefully pilfered from https://stackoverflow.com/questions/52911812/check-if-url-exists-in-r

Value

returns TRUE if the url exists

See Also

HEAD, GET, status_code

Other helper: load_catalog_csv_as_DT(), marco(), print_error_block(), print_warning_block(), util_unzip()

Examples

#EXAMPLE1
some_urls <-
c(
  "https://jimcoll.github.io/a/bad/programmer/",    # Should 404
  "https://github.com/NOAA-OWP/inundation-mapping", # Should exist
  "https://nooneshouldeverhavethisurl.gov/badtest"  # Does not exist in any form
)
data.frame(
  exists = sapply(some_urls, url_exists, USE.NAMES = FALSE),
  some_urls,
  stringsAsFactors = FALSE
) %>% tibble::as_tibble() %>% print()

util_g_to_geom_pts

Description

A wrapper of a few different utilities across rrassler to read files in directly as points

Usage

util_g_to_geom_pts(geom_path, units, proj_string, quiet = FALSE)

Arguments

geom_path

path to a file to parse

units

units found in the project, "English Units" or "SI Units"

proj_string

a projection string to apply

quiet

flag to determine whether print statements are suppressed, TRUE to suppress messages and FALSE to show them, Default: FALSE

Details

DETAILS

Value

sf points

See Also

glob2rx, read.table glue as.data.table str_split, str_trim, str_flatten sf_linestring sf, st_cast fill

Examples

## Not run: 
if(interactive()){
 #EXAMPLE1
 }

## End(Not run)

unzip nested folders

Description

unzips nested zip files

Usage

util_unzip(zippath, is_quiet = FALSE)

Arguments

zippath

path to zip

is_quiet

flag to determine whether print statements are suppressed, TRUE to suppress messages and FALSE to show them, Default: FALSE

Details

DETAILS

Value

unzipped dir

See Also

str_sub unzip glue setops

Other helper: load_catalog_csv_as_DT(), marco(), print_error_block(), print_warning_block(), url_exists()

Examples

## Not run: 
if(interactive()){
 #EXAMPLE1
 RRASSLER::util_unzip(file.path(database_path,"_temp","BLE",HUCID,glue::glue("{HUCID}_models.zip"),fsep = .Platform$file.sep),is_quiet = is_quiet)
 }

## End(Not run)

xs_to_transect_picker

Description

Picks transects

Usage

xs_to_transect_picker(
  path_to_ras_dbase = NULL,
  line_select_subset = NULL,
  hf_lines,
  reference_divides,
  reference_flowlines,
  existing_transects,
  existing_points,
  overwrite = FALSE,
  is_verbose = TRUE,
  test_limit = NULL
)

Arguments

path_to_ras_dbase

The path to the folder in which you are building your catalog, Default: NULL

line_select_subset

PARAM_DESCRIPTION, Default: NULL

hf_lines

Hydrofabric lines

reference_divides

reference divide paths

reference_flowlines

reference flowline paths

existing_transects

reference transect paths

existing_points

reference points paths

overwrite

overwrite files if we find identical models, Default: FALSE

is_verbose

flag to determine whether internal print statements (i.e. cross section parsing, vdat trans, file info) are suppressed, TRUE to show these messages and FALSE to suppress them, Default: FALSE

test_limit

Number of transects to use, Default: NULL

Details

DETAILS

Value

selected HEC-RAS lines in hd3d form

See Also

st_read, st_as_sf, st_crs, st_transform, sf, sfc, st_cast, st_line_sample, st_as_sfc, st_bbox, geos_binary_ops, st_nearest_feature, geos_measures, st_coordinates, st_write read_parquet, open_dataset, write_parquet compute, mutate, row_number glue

Examples

## Not run: 
if(interactive()){
 #EXAMPLE1
 xs_to_transect_picker(path_to_ras_dbase = NULL,line_select_subset = NULL,hf_lines,overwrite = FALSE,is_verbose = TRUE)
 }

## End(Not run)

xyz_to_ls

Description

helper to transform points into linestrings

Usage

xyz_to_ls(dat = NULL, path_to_ras_dbase = NULL, is_quiet = FALSE)

Arguments

dat

The dataframe of points, Default: NULL

path_to_ras_dbase

The path to the folder in which you are building your catalog, is also location agnostic (disk or cloud), Default: NULL

is_quiet

PARAM_DESCRIPTION, Default: FALSE

Details

DETAILS

Value

linestrings

See Also

read_parquet sf_linestring st_crs

Examples

## Not run: 
if(interactive()){
 #EXAMPLE1
 }

## End(Not run)