Lookup function for a single COMID from S3 GeoParquet (optionally restricted to one HUC2). Queries one COMID from an S3-hosted, HUC2-partitioned GeoParquet dataset and returns an sf object. If `huc2` is provided, only that partition is scanned (fastest). If not, the function tries a glob over all HUC2 partitions and falls back to a shallower pattern if needed. The function: - loads DuckDB httpfs (S3) extension, - pushes an equality filter on `COMID` for row-group/file pruning, - converts WKB geometry to sf with the CRS you provide (default EPSG:4326).
lc_get_watershed(
comid,
huc2 = NA_character_,
huc2_filter = NULL,
bucket = "dmap-data-commons-ow",
prefix = "data/streamcat/LakeCatWatersheds/",
region = "us-east-1",
install_missing = FALSE,
keep_open = FALSE,
verbose = TRUE,
progress = TRUE,
threads = 4,
enable_object_cache = TRUE,
skip_describe = FALSE,
skip_counts = TRUE,
sf_crs = 4326,
retries = 5,
retry_base_delay = 0.5,
retry_max_delay = 8,
url_style = c("path", "virtual_hosted"),
s3_endpoint = NULL
)Scalar COMID to query (numeric or character, required).
Optional two-digit HUC2 string (e.g., "01") to restrict search to one partition.
Optional character vector of HUC2s to read (e.g., c("01","05")) for multi-partition pruning.
Character(1). S3 bucket (default "dmap-data-commons-ow").
Character(1). S3 prefix under the bucket (default "data/streamcat/LakeCatWatersheds/").
Character(1). S3 region (default "us-east-1").
Logical. Install missing packages (duckdb, DBI, sf, wk) if needed (default FALSE).
Logical. Keep the DuckDB connection open (default FALSE). Note: the connection is not returned.
Logical. Print progress messages (default TRUE).
Logical. Show a simple progress bar (default TRUE).
Integer or NULL. If set, `PRAGMA threads` for DuckDB (parallelism).
Logical. Enable DuckDB object cache to speed repeated queries (default TRUE).
Logical. Skip DESCRIBE step (default FALSE).
Logical. Skip HUC2 counts step (default TRUE; no longer returned).
Integer or character. CRS for the output sf object (default 4326).
Integer. Number of retries for transient S3/HTTP errors (default 5).
Numeric. Initial exponential backoff delay in seconds (default 0.5).
Numeric. Maximum backoff delay per attempt in seconds (default 8).
Character. S3 URL style used by DuckDB httpfs, one of "path" or "virtual_hosted". Passed to `match.arg()`, default "path".
Optional character(1). Custom S3 endpoint hostname (e.g., "s3.amazonaws.com"). NULL uses the default for the selected region.
An sf object with zero or one+ rows (if multiple features share the same COMID).