Queries environmental bottle cast data with temporal, depth, and variable filters. Returns a dbplyr lazy table for efficient downstream processing.
get_env(env_var, qtr, date_range, min_depth, max_depth)Character string of database column name for environmental variable (e.g., "t_deg_c", "salnty")
Character or numeric vector of quarters to include (1-4)
Date vector of length 2 (start date, end date)
Numeric minimum depth in meters
Numeric maximum depth in meters
dbplyr lazy table with columns:
date - date of cast
time - time of cast (seconds since midnight)
dtime - datetime (computed via SQL CAST and INTERVAL)
depthm - depth in meters
lat_dec - latitude (decimal degrees)
lon_dec - longitude (decimal degrees)
qty - renamed environmental variable value
hex_h3res* - H3 hexagon indices at multiple resolutions
The function joins cast and bottle tables, then joins with
site to obtain H3 spatial indices. Only records with non-NA values
for the selected variable are returned. Datetime is constructed from separate
date and time fields using DuckDB SQL.
prep_env_hex for spatial aggregation
prep_ts_env for temporal aggregation