Calculate missing station data for XerMtn and CondQR50

calcgis(station)

Arguments

station

data.frame for input station data

Value

The original station data with calculated fields where applicable.

Details

XerMtn is calculated from PSA6C if the latter is present with no NA value. If XerMtn is present with NA values, PSA6C is used if present with no NA values. XerMtn = 1 if PSA6C is 'SN', 'NC', otherwise XerMtn = 0 if PSA6C is 'CH', 'CV', 'DM', 'SC'.

CondQR50 is calculated from the quantregForest object in rfmods if all predictors are present in stations and no missing values are in the predictors. Similar to XerMtn, NA values will be predicted per row only if the column already exists. The required predictors are 'CaO_Mean', 'MgO_Mean', 'S_Mean', 'UCS_Mean', 'LPREM_mean', 'AtmCa', 'AtmMg', 'AtmSO4', 'MINP_WS', 'MEANP_WS', 'SumAve_P', 'TMAX_WS', 'XWD_WS', 'MAXWD_WS', 'LST32AVE', 'BDH_AVE', 'KFCT_AVE', 'PRMH_AVE'.

See also

Examples

# this calculates CondQR50 and XerMtn calcgis(demo_station)
#> # A tibble: 3 x 27 #> StationCode CondQR50 SITE_ELEV TEMP_00_09 KFCT_AVE AtmCa PPT_00_09 MAX_ELEV #> <chr> <dbl> <int> <int> <dbl> <dbl> <dbl> <int> #> 1 404M07357 800 199 2456 0.278 0.0554 55570. 783 #> 2 801M16916 365. 197 2685 0.185 0.0652 25406. 3480 #> 3 909M24937 316. 582 2442 0.202 0.106 37972. 1980 #> # … with 19 more variables: CaO_Mean <dbl>, MgO_Mean <dbl>, S_Mean <dbl>, #> # UCS_Mean <dbl>, LPREM_mean <dbl>, AtmMg <dbl>, AtmSO4 <dbl>, MINP_WS <dbl>, #> # MEANP_WS <dbl>, SumAve_P <dbl>, TMAX_WS <dbl>, XWD_WS <dbl>, #> # MAXWD_WS <dbl>, LST32AVE <dbl>, BDH_AVE <dbl>, PRMH_AVE <dbl>, PSA6C <chr>, #> # XerMtn <dbl>, AREA_SQKM <dbl>
if (FALSE) { # get XerMtn from PSA6c tmp <- demo_station[, !names(demo_station) %in% 'XerMtn'] calcgis(tmp) # error, cannot get XerMtn if PSA6C not found tmp <- demo_station[, !names(demo_station) %in% c('XerMtn', 'PSA6C')] calcgis(tmp) # get conductivity tmp <- demo_station calcgis(tmp) # get conductivity for only NA tmp <- demo_station tmp$CondQR50[1] <- 200 calcgis(tmp) # error, cannot calculate conductivity if missing predictors tmp <- demo_station[, !names(demo_station) %in% c('TMAX_WS', 'AtmSO4')] calcgis(tmp) # error, cannot calculate conductivity if missing values in predictors tmp <- demo_station tmp$MINP_WS[2] <- NA tmp$AtmSO4[3] <- NA calcgis(tmp) }