% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/lc_get_watershed.R
\name{lc_get_watershed}
\alias{lc_get_watershed}
\title{Get LakeCat Lake Watershed}
\usage{
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
)
}
\arguments{
\item{comid}{Scalar COMID to query (numeric or character, required).}

\item{huc2}{Optional two-digit HUC2 string (e.g., "01") to restrict search to one partition.}

\item{huc2_filter}{Optional character vector of HUC2s to read (e.g., c("01","05")) for multi-partition pruning.}

\item{bucket}{Character(1). S3 bucket (default "dmap-data-commons-ow").}

\item{prefix}{Character(1). S3 prefix under the bucket (default "data/streamcat/LakeCatWatersheds/").}

\item{region}{Character(1). S3 region (default "us-east-1").}

\item{install_missing}{Logical. Install missing packages (duckdb, DBI, sf, wk) if needed (default FALSE).}

\item{keep_open}{Logical. Keep the DuckDB connection open (default FALSE). Note: the connection is not returned.}

\item{verbose}{Logical. Print progress messages (default TRUE).}

\item{progress}{Logical. Show a simple progress bar (default TRUE).}

\item{threads}{Integer or NULL. If set, `PRAGMA threads` for DuckDB (parallelism).}

\item{enable_object_cache}{Logical. Enable DuckDB object cache to speed repeated queries (default TRUE).}

\item{skip_describe}{Logical. Skip DESCRIBE step (default FALSE).}

\item{skip_counts}{Logical. Skip HUC2 counts step (default TRUE; no longer returned).}

\item{sf_crs}{Integer or character. CRS for the output sf object (default 4326).}

\item{retries}{Integer. Number of retries for transient S3/HTTP errors (default 5).}

\item{retry_base_delay}{Numeric. Initial exponential backoff delay in seconds (default 0.5).}

\item{retry_max_delay}{Numeric. Maximum backoff delay per attempt in seconds (default 8).}

\item{url_style}{Character. S3 URL style used by DuckDB httpfs, one of "path" or "virtual_hosted".
Passed to `match.arg()`, default "path".}

\item{s3_endpoint}{Optional character(1). Custom S3 endpoint hostname (e.g., "s3.amazonaws.com").
NULL uses the default for the selected region.}
}
\value{
An sf object with zero or one+ rows (if multiple features share the same COMID).
}
\description{
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).
}
