| Title: | Catchment Attributes and Meteorology for Peru (CAMELS-PE) |
|---|---|
| Description: | Download, load, manage, and filter the Catchment Attributes and Meteorology for Large-Sample Studies - Peru (CAMELS-PE) dataset for hydroclimatic and hydrological analysis. Offers high-performance reading and manipulation of large datasets using the 'arrow' and 'collapse' packages. Provides tools to extract catchment-scale meteorological time series, physical attributes, and spatial boundaries for 136 catchments, with 10 daily variables on the 1981-2025 calendar and 79 attributes. CAMELS-PE data are distributed separately under CC BY 4.0 <doi:10.5281/zenodo.21195425>. |
| Authors: | Paul E. Santos Andrade [aut, cre, cph] (ORCID: <https://orcid.org/0000-0002-6635-0375>) |
| Maintainer: | Paul E. Santos Andrade <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-11-07 22:35:58 UTC |
| Source: | https://github.com/cran/rcamelspe |
Compatibility alias matching RCamelsPE::download_camels_pe().
download_camels_pe( path, version = "1.0.1", unzip = TRUE, overwrite = FALSE, set_path = TRUE )download_camels_pe( path, version = "1.0.1", unzip = TRUE, overwrite = FALSE, set_path = TRUE )
path |
Character string. Destination directory where dataset will be stored. |
version |
Character string. Dataset release: |
unzip |
Logical. Should the downloaded file be extracted? Default is |
overwrite |
Logical. If |
set_path |
Logical. If |
Character string indicating the path to the downloaded archive or directory.
download_camels_pe(path = tempdir(), unzip = FALSE)download_camels_pe(path = tempdir(), unzip = FALSE)
Downloads the CAMELS-PE dataset zip file from the Zenodo repository (doi:10.5281/zenodo.21195425) and extracts it in the destination folder.
download_pe_data( dest_dir, unzip = TRUE, overwrite = FALSE, quiet = FALSE, version = "1.0.1", set_path = TRUE )download_pe_data( dest_dir, unzip = TRUE, overwrite = FALSE, quiet = FALSE, version = "1.0.1", set_path = TRUE )
dest_dir |
Character string. Destination directory where the dataset should be saved. |
unzip |
Logical. Should the downloaded file be unzipped? Default is |
overwrite |
Logical. If destination files already exist, should they be overwritten?
Default is |
quiet |
Logical. Should download progress be suppressed? Default is |
version |
Character string. Dataset release: |
set_path |
Logical. Configure the session path after extraction only. |
Character string indicating the directory path where the dataset is located
or extracted; the ZIP path when unzip = FALSE. Use a separate destination
for each release, or overwrite = TRUE to replace an existing extraction.
# Download to a temporary folder download_pe_data(dest_dir = tempdir())# Download to a temporary folder download_pe_data(dest_dir = tempdir())
Retrieves the path to the CAMELS-PE dataset directory. It looks up paths in the following order of precedence:
The package option rcamelspe.path.
The environment variable CAMELS_PE_PATH.
The persistent user data directory (tools::R_user_dir("rcamelspe", "data")).
Default search paths in the current working directory (raw-data/CAMELS-PE,
data-raw/CAMELS-PE, etc.).
The bundled minimal sample dataset in inst/extdata/sample_camels_pe.
get_camels_pe_path() get_camels_path()get_camels_pe_path() get_camels_path()
Character string containing the directory path where the dataset is located,
or NULL if no valid path is found.
camels_path <- get_camels_pe_path() is.character(camels_path)camels_path <- get_camels_pe_path() is.character(camels_path)
Loads one or more catchment attribute files and merges them by gauge_id.
High-performance implementation using 'arrow' and 'collapse'.
load_pe_attributes( attributes = "all", gauge_ids = NULL, variables = NULL, path = get_camels_pe_path() )load_pe_attributes( attributes = "all", gauge_ids = NULL, variables = NULL, path = get_camels_pe_path() )
attributes |
Character vector. The attribute groups to load. Can be any combination of
|
gauge_ids |
Character vector. Optional gauge identifiers to filter the returned attributes.
If |
variables |
Character vector or |
path |
Character string. Path to the CAMELS-PE dataset directory. If |
CAMELS-PE v1.0.1 documents 79 attributes in seven thematic tables. Hydrological signatures are derived from simulated streamflow, not observations.
A data.frame containing the merged catchment attributes with gauge_id
as primary identifier.
# Load all attributes merged attrs_all <- load_pe_attributes() head(attrs_all) # Load only topographic and climatic attributes attrs_sub <- load_pe_attributes(c("topographic", "climatic")) head(attrs_sub) # Load attributes for specific stations attrs_sel <- load_pe_attributes(gauge_ids = c("PE_110139", "PE_111151")) attrs_sel# Load all attributes merged attrs_all <- load_pe_attributes() head(attrs_all) # Load only topographic and climatic attributes attrs_sub <- load_pe_attributes(c("topographic", "climatic")) head(attrs_sub) # Load attributes for specific stations attrs_sel <- load_pe_attributes(gauge_ids = c("PE_110139", "PE_111151")) attrs_sel
Loads geospatial catchment boundary polygons or gauging station point locations
from the CAMELS-PE dataset as sf spatial objects.
load_pe_geospatial( type = c("catchments", "gauges"), gauge_ids = NULL, path = get_camels_pe_path() )load_pe_geospatial( type = c("catchments", "gauges"), gauge_ids = NULL, path = get_camels_pe_path() )
type |
Character string. Either |
gauge_ids |
Character vector. Station identifiers to filter the spatial features.
If |
path |
Character string. Path to the CAMELS-PE dataset directory. If |
An sf spatial data frame object containing the requested geometries and
station attributes.
# Load all catchment boundaries catchments <- load_pe_geospatial(type = "catchments") catchments # Load specific gauging stations gauges_sub <- load_pe_geospatial(type = "gauges", gauge_ids = "PE_110139") gauges_sub# Load all catchment boundaries catchments <- load_pe_geospatial(type = "catchments") catchments # Load specific gauging stations gauges_sub <- load_pe_geospatial(type = "gauges", gauge_ids = "PE_110139") gauges_sub
Loads gauging station metadata or the data dictionary from the CAMELS-PE dataset.
load_pe_metadata( type = c("stations", "dictionary"), category = NULL, variable = NULL, file = NULL, path = get_camels_pe_path() )load_pe_metadata( type = c("stations", "dictionary"), category = NULL, variable = NULL, file = NULL, path = get_camels_pe_path() )
type |
Character string. Either |
category |
Character vector or |
variable |
Character vector or |
file |
Character vector or |
path |
Character string. Path to the CAMELS-PE dataset directory. If |
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.
# Load stations metadata stations <- load_pe_metadata(type = "stations") head(stations) # Load data dictionary data_dict <- load_pe_metadata(type = "dictionary") head(data_dict) # Load data dictionary filtered by category clim_dict <- load_pe_metadata(type = "dictionary", category = "climatic")# Load stations metadata stations <- load_pe_metadata(type = "stations") head(stations) # Load data dictionary data_dict <- load_pe_metadata(type = "dictionary") head(data_dict) # Load data dictionary filtered by category clim_dict <- load_pe_metadata(type = "dictionary", category = "climatic")
Efficiently loads daily hydroclimatic timeseries for Peruvian catchments. Features an optimized dual-pathway execution engine using 'arrow' and 'collapse':
For selective requests, reads individual catchment files with column projection.
For global or multi-catchment requests, uses arrow::open_dataset() with
predicate pushdown (filtering stations and date ranges directly at scan time)
to minimize memory footprint and maximize throughput.
load_pe_timeseries( gauge_ids = NULL, variables = NULL, start_date = NULL, end_date = NULL, path = get_camels_pe_path(), parse_dates = TRUE, use_arrow = TRUE, global = FALSE )load_pe_timeseries( gauge_ids = NULL, variables = NULL, start_date = NULL, end_date = NULL, path = get_camels_pe_path(), parse_dates = TRUE, use_arrow = TRUE, global = FALSE )
gauge_ids |
Character vector. Station/catchment identifiers (e.g. |
variables |
Character vector. Names of hydroclimatic variables to select.
If |
start_date |
Optional character string or Date object ( |
end_date |
Optional character string or Date object ( |
path |
Character string. Path to the CAMELS-PE dataset directory. If |
parse_dates |
Logical. Should the |
use_arrow |
Logical. Should the 'arrow' package be used for reading?
Default is |
global |
Logical. If |
The common calendar is 1981-2025; unavailable observations remain NA.
Streamflow is expressed in mm/day, precipitation variance (prec_var) in
mm^2/day^2, solar radiation in MJ/m^2/day, and vapor pressure in hPa.
Identifier columns date and gauge_id may also be requested in variables.
Automatic routing compares selected CSV bytes plus a 4 MiB per-file opening
cost estimate against the master CSV size. This heuristic avoids scanning
the national file for small subsets while retaining it for large requests.
Missing individual files fall back to the master when it is available.
global = TRUE always forces the master. No data cache is created.
A data.frame containing daily hydroclimatic timeseries data with at least
date and gauge_id columns, plus the requested hydrometeorological variables.
# Load timeseries for a specific station ts_station <- load_pe_timeseries(gauge_ids = "PE_110139") head(ts_station) # Load only precipitation and observed streamflow with date range filter ts_sub <- load_pe_timeseries( gauge_ids = "PE_110139", variables = c("prec", "flow_obs"), start_date = "2000-01-01", end_date = "2000-03-31" ) head(ts_sub)# Load timeseries for a specific station ts_station <- load_pe_timeseries(gauge_ids = "PE_110139") head(ts_station) # Load only precipitation and observed streamflow with date range filter ts_sub <- load_pe_timeseries( gauge_ids = "PE_110139", variables = c("prec", "flow_obs"), start_date = "2000-01-01", end_date = "2000-03-31" ) head(ts_sub)
Creates a thematic map of CAMELS-PE catchments using a selected attribute.
The function joins attribute data with catchment geometries by gauge_id
using collapse::join and returns a ggplot object.
plot_pe_attribute_map( catchments, attributes, variable, gauges = NULL, na_color = "grey80", ... ) plot_attribute_map( catchments, attributes, variable, gauges = NULL, na_color = "grey80", ... )plot_pe_attribute_map( catchments, attributes, variable, gauges = NULL, na_color = "grey80", ... ) plot_attribute_map( catchments, attributes, variable, gauges = NULL, na_color = "grey80", ... )
catchments |
An |
attributes |
A data frame containing CAMELS-PE attributes. |
variable |
Character string. Name of the attribute to visualize. |
gauges |
Optional |
na_color |
Character string. Color for missing values. Default is |
... |
Additional arguments passed to |
A ggplot object visualizing the attribute map.
catchments <- load_pe_geospatial(type = "catchments") attrs <- load_pe_attributes(attributes = "topographic") plot_pe_attribute_map(catchments, attrs, variable = "area")catchments <- load_pe_geospatial(type = "catchments") attrs <- load_pe_attributes(attributes = "topographic") plot_pe_attribute_map(catchments, attrs, variable = "area")
Creates a map of CAMELS-PE catchments and optionally overlays gauge
locations. If gauge_id is provided, only one catchment and its outlet
are plotted, with the gauge ID shown as a panel header.
plot_pe_catchments( catchments, gauges = NULL, gauge_id = NULL, fill = NULL, ... ) plot_catchments(catchments, gauges = NULL, gauge_id = NULL, fill = NULL, ...)plot_pe_catchments( catchments, gauges = NULL, gauge_id = NULL, fill = NULL, ... ) plot_catchments(catchments, gauges = NULL, gauge_id = NULL, fill = NULL, ...)
catchments |
An |
gauges |
Optional |
gauge_id |
Optional character string. Gauge ID used to filter one
catchment and its gauge before plotting. If |
fill |
Optional character string. Name of a catchment column used to
fill polygons. If |
... |
Additional arguments passed to |
A ggplot object with the spatial catchment geometries.
catchments <- load_pe_geospatial(type = "catchments") gauges <- load_pe_geospatial(type = "gauges") plot_pe_catchments(catchments, gauges)catchments <- load_pe_geospatial(type = "catchments") gauges <- load_pe_geospatial(type = "gauges") plot_pe_catchments(catchments, gauges)
Creates a time series plot for one CAMELS-PE variable, such as precipitation,
observed streamflow, simulated streamflow, or temperature. The function
returns a ggplot object, styled with the project color palette.
plot_pe_timeseries( data, variable = "flow_obs", gauge_id = NULL, date_col = "date", facet = TRUE, scales = "free_y", line_color = "#2F4156", ... ) plot_timeseries( data, variable = "flow_obs", gauge_id = NULL, date_col = "date", facet = TRUE, scales = "free_y", line_color = "#2F4156", ... )plot_pe_timeseries( data, variable = "flow_obs", gauge_id = NULL, date_col = "date", facet = TRUE, scales = "free_y", line_color = "#2F4156", ... ) plot_timeseries( data, variable = "flow_obs", gauge_id = NULL, date_col = "date", facet = TRUE, scales = "free_y", line_color = "#2F4156", ... )
data |
A data frame containing CAMELS-PE time series. |
variable |
Character string. Name of the variable to plot. Default is |
gauge_id |
Optional character vector. Gauge IDs used to filter the data
before plotting. If |
date_col |
Character string. Name of the date column. Default is |
facet |
Logical value. If |
scales |
Character string. Scales passed to |
line_color |
Character string. Line color for the time series. Default is |
... |
Additional arguments passed to |
A ggplot visualization object representing the time series.
ts <- load_pe_timeseries( gauge_ids = "PE_110139", variables = c("prec", "flow_sim") ) plot_pe_timeseries(ts, variable = "prec")ts <- load_pe_timeseries( gauge_ids = "PE_110139", variables = c("prec", "flow_sim") ) plot_pe_timeseries(ts, variable = "prec")
Compatibility alias matching the RCamelsPE::read_attributes() interface,
powered by the high-performance 'arrow' and 'collapse' backend of rcamelspe.
read_attributes( type = "all", gauge_id = NULL, vars = NULL, path = get_camels_pe_path() )read_attributes( type = "all", gauge_id = NULL, vars = NULL, path = get_camels_pe_path() )
type |
Character string. Attribute group to read. One of
|
gauge_id |
Character vector or |
vars |
Character vector or |
path |
Character string. Optional path to the CAMELS-PE root directory. |
A data.frame with CAMELS-PE catchment attributes.
# Read all attributes using RCamelsPE compatible syntax attrs <- read_attributes(type = "topographic") head(attrs)# Read all attributes using RCamelsPE compatible syntax attrs <- read_attributes(type = "topographic") head(attrs)
Reads the CAMELS-PE data dictionary with optional filters by category,
variable, or source file. Compatible with the RCamelsPE interface.
read_dictionary( category = NULL, variable = NULL, file = NULL, path = get_camels_pe_path() )read_dictionary( category = NULL, variable = NULL, file = NULL, path = get_camels_pe_path() )
category |
Character vector or |
variable |
Character vector or |
file |
Character vector or |
path |
Character string. Optional path to the CAMELS-PE root directory.
If not provided, retrieved automatically via |
A data.frame containing the CAMELS-PE data dictionary entries.
# Read full dictionary dict <- read_dictionary() head(dict) # Read dictionary for topographic category topo_dict <- read_dictionary(category = "topographic") head(topo_dict)# Read full dictionary dict <- read_dictionary() head(dict) # Read dictionary for topographic category topo_dict <- read_dictionary(category = "topographic") head(topo_dict)
Compatibility alias matching RCamelsPE::read_geospatial().
read_geospatial(type = c("gauges", "catchments"), path = get_camels_pe_path())read_geospatial(type = c("gauges", "catchments"), path = get_camels_pe_path())
type |
Character string. Either |
path |
Character string. Optional path to the CAMELS-PE root directory. |
An sf spatial object.
catchments <- read_geospatial(type = "catchments") head(catchments)catchments <- read_geospatial(type = "catchments") head(catchments)
Convenience alias for load_pe_metadata(type = "stations"), compatible
with the RCamelsPE interface.
read_metadata(path = get_camels_pe_path())read_metadata(path = get_camels_pe_path())
path |
Character string. Optional path to the CAMELS-PE root directory.
If not provided, retrieved automatically via |
A data.frame containing gauging station metadata.
stations <- read_metadata() head(stations)stations <- read_metadata() head(stations)
Compatibility alias matching the RCamelsPE::read_timeseries() interface,
powered by the high-performance 'arrow' dataset and 'collapse' query engine.
read_timeseries( gauge_id = NULL, global = FALSE, vars = NULL, start_date = NULL, end_date = NULL, path = get_camels_pe_path() )read_timeseries( gauge_id = NULL, global = FALSE, vars = NULL, start_date = NULL, end_date = NULL, path = get_camels_pe_path() )
gauge_id |
Character vector or |
global |
Logical value. If |
vars |
Character vector or |
start_date |
Optional character string or Date ( |
end_date |
Optional character string or Date ( |
path |
Character string. Optional path to the CAMELS-PE root directory. |
A data.frame containing CAMELS-PE time series data.
# Read timeseries using RCamelsPE compatible syntax ts <- read_timeseries(gauge_id = "PE_110139", vars = c("date", "prec", "flow_obs")) head(ts)# Read timeseries using RCamelsPE compatible syntax ts <- read_timeseries(gauge_id = "PE_110139", vars = c("date", "prec", "flow_obs")) head(ts)
Sets the path to the directory containing the CAMELS-PE dataset. The path is stored in the package session options.
set_camels_pe_path(path) set_camels_path(path)set_camels_pe_path(path) set_camels_path(path)
path |
Character string. Path to the CAMELS-PE dataset directory. |
Invisible NULL. Called for its side effect of setting the dataset path.
old_path <- getOption("rcamelspe.path") sample_path <- system.file("extdata", "sample_camels_pe", package = "rcamelspe") set_camels_pe_path(sample_path) # Reset options options(rcamelspe.path = old_path)old_path <- getOption("rcamelspe.path") sample_path <- system.file("extdata", "sample_camels_pe", package = "rcamelspe") set_camels_pe_path(sample_path) # Reset options options(rcamelspe.path = old_path)