setPrjMatrix: Sets the matrix of parameter values in a CRHM model '.prj'...

View source: R/setPrjMatrix.R

setPrjMatrixR Documentation

Sets the matrix of parameter values in a CRHM model .prj file

Description

Replaces the existing values of a single parameter, for all HRUs, in a .prj file.

Usage

setPrjMatrix(
  inputPrjFile = "",
  paramName = NULL,
  paramMatrix = NULL,
  outputPrjFile = "",
  decimals = 0,
  quiet = TRUE,
  logfile = ""
)

Arguments

inputPrjFile

Required. Name of the .prj file.

paramName

Required. Name of parameter to set.

paramMatrix

Required. Square matrix containing new parameter values. There must be at as many rows and columns in this vector as HRUs in the orginal .prj file.

outputPrjFile

Optional. If omitted, the input .prj file will be overwritten.

decimals

Optional. If 0, number of decimal places in output is not set. If >0, number of decimal places in output is fixed.

quiet

Optional. Suppresses display of messages, except for errors. If you are calling this function in an R script, you will usually leave quiet=TRUE (i.e. the default). If you are working interactively, you will probably want to set quiet=FALSE.

logfile

Optional. Name of the file to be used for logging the action. Normally not used.

Value

If successful, returns TRUE. If unsuccessful, returns FALSE.

Note

Currently, this function has only been tested on simple .prj files, i.e. without REW Grp parameters. It might work for complex files if the REW Grp specification is included in the parameter name.

Author(s)

Kevin Shook

See Also

readPrjMatrix

Examples

## Not run: 
prj_file <- "Cluster1_PTH_100km2_WFDEI-GEM_new_watershed10_50%_IN.prj"
distrib_route_vals <- readPrjMatrix(prj_file, "distrib_Route")
distrib_route_vals[, 10] <- 0
result <- setPrjMatrix(prj_file, "distrib_Route",distrib_route_vals))
## End(Not run)

CentreForHydrology/CRHMr documentation built on April 6, 2024, 5:27 p.m.