Skip to contents

Convenience wrapper around ok_lake_ecoregions for retrieving the ecoregion assignment for one or more lakes. Always returns a data frame so that the return type is stable across single-match and multi-match results.

To get a bare ecoregion name string for use in ok_load(), use:

eco <- ok_lake_ecoregion("Arcadia Lake", exact = TRUE)$eco_l3_name

Usage

ok_lake_ecoregion(lake_name, exact = FALSE, simplify = NULL)

Arguments

lake_name

Character. One or more lake names to look up. Partial matching is supported (case-insensitive) unless exact is TRUE.

exact

Logical. If TRUE, requires an exact name match (case-insensitive). Default FALSE.

simplify

Deprecated. Retained for backward compatibility with pre-0.1.3 callers; ignored with a deprecation warning. The function always returns a data frame.

Value

A data frame of zero or more rows from ok_lake_ecoregions with all columns. An unmatched lookup returns an empty data frame (with the correct column structure) plus a warning.

Examples

# Standard usage: exact match, extract ecoregion name
eco <- ok_lake_ecoregion("Arcadia Lake", exact = TRUE)$eco_l3_name
eco
#> [1] "Cross Timbers"

# Partial match: returns a data frame of all matches
ok_lake_ecoregion("Tenkiller")
#>              lake_name eco_l3_code     eco_l3_name n_sites_total n_sites_tier1
#> 1 Tenkiller Ferry Lake          39 Ozark Highlands             7             7
#>   latitude longitude max_yrs_tp max_yrs_chla max_yrs_secchi max_yrs_tn
#> 1  35.7055 -94.95351         17           17             17         17

# Use in pipeline
eco <- ok_lake_ecoregion("Arcadia Lake", exact = TRUE)$eco_l3_name
if (length(eco) == 1L && !is.na(eco)) {
  ok_load(inflow_m3yr   = 45e6,
          tp_inflow_ugl = 120,
          coefficients  = "oklahoma",
          ecoregion     = eco)
}
#> -- okBATHTUB Result --
#>   Pipeline step : load
#>   Segment       : main
#>   Coefficients  : oklahoma
#> 
#>   inflow_m3yr    : 4.5e+07
#>   tp_inflow_ugl  : 120
#>   tp_load_kgyr   : 5400