Skip to contents

Loads gauging station metadata or the data dictionary from the CAMELS-PE dataset.

Usage

load_pe_metadata(
  type = c("stations", "dictionary"),
  category = NULL,
  variable = NULL,
  file = NULL,
  path = get_camels_pe_path()
)

Arguments

type

Character string. Either "stations" to load gauging station metadata or "dictionary" to load the data dictionary.

category

Character vector or NULL. Optional category filter for the dictionary (e.g. "climatic").

variable

Character vector or NULL. Optional variable filter for the dictionary (e.g. "flow_obs").

file

Character vector or NULL. Optional file filter for the dictionary (e.g. "stations.csv").

path

Character string. Path to the CAMELS-PE dataset directory. If NULL, retrieved automatically via get_camels_pe_path().

Value

A data.frame containing the requested metadata:

  • When type = "stations": station metadata including gauge_id, gauge_name, geographic coordinates, elevation, and hydrologic regions.

  • When type = "dictionary": dictionary entries with columns folder, file, category, variable, description, unit, and source.

Examples

# Load stations metadata
stations <- load_pe_metadata(type = "stations")
head(stations)
#>      gauge_id             gauge_name gauge_region gauge_lat gauge_lon
#> 1 PE_472A9204                 Chilca     Atlantic   -13.223   -72.343
#> 2   PE_210003             Huancasaya     Titicaca   -15.142   -69.213
#> 3   PE_204617               Huatiapa      Pacific   -16.009   -72.483
#> 4 PE_472935F2      Intihuatana Km105     Atlantic   -13.185   -72.524
#> 5   PE_210406 Puente Isla Cabanillas     Titicaca   -15.473   -70.222
#> 6   PE_270503       Puente Zapatilla     Titicaca   -16.140   -69.585
#>   gauge_elev gauge_record_start gauge_record_end gauge_perc_obs
#> 1       2770         2017-09-01       2022-09-05          11.07
#> 2       4327         2022-03-01       2025-12-31           7.36
#> 3        684         1998-01-10       2025-12-31          48.38
#> 4       2166         2012-09-01       2025-12-31          27.23
#> 5       3837         1994-07-16       2025-12-31          37.77
#> 6       3836         1985-06-01       2025-12-31          44.13
#>           name_cat is_nested nested_group_id nested_group_size
#> 1  Cuenca Urubamba      TRUE      PE_2401081                54
#> 2    Cuenca Suches     FALSE       PE_210003                 1
#> 3    Cuenca Camaná     FALSE       PE_204617                 1
#> 4  Cuenca Urubamba      TRUE      PE_2401081                54
#> 5     Cuenca Coata      TRUE       PE_210407                 4
#> 6 Intercuenca 0157     FALSE       PE_270503                 1
#>   downstream_gauge_id upstream_gauge_id
#> 1         PE_472935F2       PE_472A6280
#> 2                NONE              NONE
#> 3                NONE              NONE
#> 4       PE_4994910001       PE_472A9204
#> 5           PE_210407         PE_270300
#> 6                NONE              NONE

# Load data dictionary
data_dict <- load_pe_metadata(type = "dictionary")
head(data_dict)
#>        folder         file category     variable
#> 1 01_metadata stations.csv metadata     gauge_id
#> 2 01_metadata stations.csv metadata   gauge_name
#> 3 01_metadata stations.csv metadata gauge_region
#> 4 01_metadata stations.csv metadata    gauge_lat
#> 5 01_metadata stations.csv metadata    gauge_lon
#> 6 01_metadata stations.csv metadata   gauge_elev
#>                                description  unit  source
#> 1 Catchment identifier provided by SENAMHI     - SENAMHI
#> 2           Gauge name provided by SENAMHI     - SENAMHI
#> 3                      Hydrographic region     - SENAMHI
#> 4                   Gauge latitude (WGS84)  degN SENAMHI
#> 5                  Gauge longitude (WGS84)  degE SENAMHI
#> 6                          Gauge elevation m_asl SENAMHI

# Load data dictionary filtered by category
clim_dict <- load_pe_metadata(type = "dictionary", category = "climatic")