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 |
adds helper fields to accounting.csv.
append_catalog_fields( path_to_ras_dbase = NULL, out_name = NULL, overwrite = FALSE, is_verbose = TRUE, HUC8_override = NULL )
append_catalog_fields( path_to_ras_dbase = NULL, out_name = NULL, overwrite = FALSE, is_verbose = TRUE, HUC8_override = NULL )
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 |
TRUE
a new csv with helper columns
glue
mutate
s2
, st_transform
, st_read
, st_crs
fwrite
Other post-process:
refresh_master_files()
## 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)
## 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)
Depreciated - add a file as a record in the RRASSLED structure - Depreciated
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 )
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 )
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 |
the cloud version of the ingest process, depreciated in favor of local pre-RRASSL
a set of files in a newly RRASSLE'd record.
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()
## Not run: if(interactive()){ #EXAMPLE1 } ## End(Not run)
## Not run: if(interactive()){ #EXAMPLE1 } ## End(Not run)
crosswalk_hull_to_hydrofabric_value
crosswalk_hull_to_hydrofabric_value(hull, river)
crosswalk_hull_to_hydrofabric_value(hull, river)
hull |
the model cross section hulls |
river |
the river streamlines |
Used to tie into hydrofabric models
The representative COMID from nhdplusTools
get_nhdplus
aoi_get
st_transform
, st_crs
## 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)
## 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)
add a file as a record in the RRASSLED structure
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 )
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 )
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 |
the disk version of the ingest process
a set of files in a newly RRASSLE'd record.
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()
## 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)
## 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)
attempts to parse datum and datum unit from file based on WKT
get_datum_from_crs(x)
get_datum_from_crs(x)
x |
either the string or the sf crs |
DETAILS
list of CRS and vertical unit
[st_crs][sf::st_crs]
## Not run: if(interactive()){ #EXAMPLE1 get_datum_from_crs("EPSG:6349") EXAMPLE2 get_datum_from_crs(sf::st_crs("EPSG:6349")) } ## End(Not run)
## Not run: if(interactive()){ #EXAMPLE1 get_datum_from_crs("EPSG:6349") EXAMPLE2 get_datum_from_crs(sf::st_crs("EPSG:6349")) } ## End(Not run)
helper to ingest FEMA region 6 BLE data
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 )
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 )
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 |
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.
a RRASSLE'd catalog of models or added desired HUC8 models
str_sub
glue
unzip
st_read
, st_crs
Other ingest:
cloud_ingest_record()
,
disk_ingest_record()
,
ingest_into_database()
## 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)
## 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 files from a source directory on your drive into a formatted input directory
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 )
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 )
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 |
here 'ingest' means add to our accounting system and database refers to our folder structure
a RRASSLE'd catalog of models
glue
str_sub
detectCores
, makeCluster
registerDoParallel
foreach
Other ingest:
cloud_ingest_record()
,
disk_ingest_record()
,
ingest_FEMA6_BLE()
## 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)
## 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)
Helper to ensure catalog edge cases and incorrect formats are correctly handled (most commonly numeric strings parsed into characters)
load_catalog_csv_as_DT(path_to_csv, is_quiet = TRUE)
load_catalog_csv_as_DT(path_to_csv, is_quiet = TRUE)
path_to_csv |
path to the model_catalog.csv file under your catalog folder |
is_quiet |
if TRUE, function will suppress message, Default: TRUE |
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"))'
returns the model_catalog as a data.table object with enforced column types
Other helper:
marco()
,
print_error_block()
,
print_warning_block()
,
url_exists()
,
util_unzip()
## 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)
## 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)
FUNCTION_DESCRIPTION
make_xs_hyfab_comp( path_to_ras_dbase = NULL, line_select_subset = NULL, hf_lines, overwrite = FALSE, is_verbose = TRUE )
make_xs_hyfab_comp( path_to_ras_dbase = NULL, line_select_subset = NULL, hf_lines, overwrite = FALSE, is_verbose = TRUE )
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
OUTPUT_DESCRIPTION
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
## 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)
## 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)
a function to help apply geographic context to the RRASSLED catalog
map_library( path_to_ras_dbase, AOI_to_map = NULL, name = "model_map", plot_lines = FALSE, chart_lines = FALSE, refresh = FALSE, quiet = TRUE )
map_library( path_to_ras_dbase, AOI_to_map = NULL, name = "model_map", plot_lines = FALSE, chart_lines = FALSE, refresh = FALSE, quiet = TRUE )
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
OUTPUT_DESCRIPTION
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
## 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)
## 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)
A hello world tester
marco()
marco()
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)
a hello world message (polo!)
Other helper:
load_catalog_csv_as_DT()
,
print_error_block()
,
print_warning_block()
,
url_exists()
,
util_unzip()
RRASSLER::marco()
RRASSLER::marco()
parse a model into an xyz dataframe from basename, considers both g## and g##.hdf files
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 )
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 )
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
OUTPUT_DESCRIPTION
## 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)
## 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)
A error block helper
print_error_block()
print_error_block()
line art to draw eyes to printing notices
print output
Other helper:
load_catalog_csv_as_DT()
,
marco()
,
print_warning_block()
,
url_exists()
,
util_unzip()
RRASSLER::print_error_block()
RRASSLER::print_error_block()
A warning block helper
print_warning_block()
print_warning_block()
line art to draw eyes to printing notices
print output
Other helper:
load_catalog_csv_as_DT()
,
marco()
,
print_error_block()
,
url_exists()
,
util_unzip()
RRASSLER::print_warning_block()
RRASSLER::print_warning_block()
process a ras g file into xyz format
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 )
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 )
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
a point database and notes about processing
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
## 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)
## 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 a ras g##.hdf file into xyz format
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 )
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 )
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
a point database and notes about processing
[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]
## 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)
## 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)
remerge individual files into spatial model key
refresh_master_files(path_to_ras_dbase, is_verbose = TRUE, overwrite = TRUE)
refresh_master_files(path_to_ras_dbase, is_verbose = TRUE, overwrite = TRUE)
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 |
TRUE
updated master index files including accounting.csv, point_database.parque, XS.fgb, and model_footprints.fgb
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()
## 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)
## 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)
Helper to download relevant BLE data
scrape_ble_lib( database_path, HUCID, is_quiet = FALSE, overwrite = overwrite, files = "m" )
scrape_ble_lib( database_path, HUCID, is_quiet = FALSE, overwrite = overwrite, files = "m" )
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' |
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.
The requested BLE data as a scraped zip file
st_transform
, st_read
, st_crs
GET
, write_disk
glue
## 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)
## 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)
A function to test if I get a response from a URL
url_exists(x, non_2xx_return_value = FALSE, is_quiet = FALSE)
url_exists(x, non_2xx_return_value = FALSE, is_quiet = FALSE)
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 |
gratefully pilfered from https://stackoverflow.com/questions/52911812/check-if-url-exists-in-r
returns TRUE if the url exists
Other helper:
load_catalog_csv_as_DT()
,
marco()
,
print_error_block()
,
print_warning_block()
,
util_unzip()
#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()
#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()
A wrapper of a few different utilities across rrassler to read files in directly as points
util_g_to_geom_pts(geom_path, units, proj_string, quiet = FALSE)
util_g_to_geom_pts(geom_path, units, proj_string, quiet = FALSE)
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
sf points
glob2rx
, read.table
glue
as.data.table
str_split
, str_trim
, str_flatten
sf_linestring
sf
, st_cast
fill
## Not run: if(interactive()){ #EXAMPLE1 } ## End(Not run)
## Not run: if(interactive()){ #EXAMPLE1 } ## End(Not run)
unzips nested zip files
util_unzip(zippath, is_quiet = FALSE)
util_unzip(zippath, is_quiet = FALSE)
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
unzipped dir
Other helper:
load_catalog_csv_as_DT()
,
marco()
,
print_error_block()
,
print_warning_block()
,
url_exists()
## 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)
## 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)
Picks transects
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 )
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 )
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
selected HEC-RAS lines in hd3d form
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
## 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)
## 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)
helper to transform points into linestrings
xyz_to_ls(dat = NULL, path_to_ras_dbase = NULL, is_quiet = FALSE)
xyz_to_ls(dat = NULL, path_to_ras_dbase = NULL, is_quiet = FALSE)
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
linestrings
read_parquet
sf_linestring
st_crs
## Not run: if(interactive()){ #EXAMPLE1 } ## End(Not run)
## Not run: if(interactive()){ #EXAMPLE1 } ## End(Not run)