% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/read_waterdata.R
\name{read_waterdata}
\alias{read_waterdata}
\title{Generalized USGS Water Data API retrieval function}
\usage{
read_waterdata(
  service,
  CQL,
  ...,
  convertType = getOption("dataRetrieval.convertType"),
  limit = getOption("dataRetrieval.limit"),
  attach_request = getOption("dataRetrieval.attach_request")
)
}
\arguments{
\item{service}{character, can be any existing collection.}

\item{CQL}{A string in a Common Query Language format.}

\item{\dots}{Additional arguments to send to the request.}

\item{convertType}{logical, defaults to \code{TRUE}. If \code{TRUE}, the function
will convert the data to dates and qualifier to string vector.}

\item{limit}{numeric, The optional limit parameter is used to control the subset of the
selected features that should be returned in each page. The maximum allowable
limit is 50,000. It may be beneficial to set this number lower if your internet
connection is spotty. The default (\code{NA}) will set the limit to the maximum
allowable limit for the service.}

\item{attach_request}{logical, defaults to TRUE.
If set to \code{TRUE}, the full request sent to the Water Data API is attached
as an attribute to the data set.}
}
\description{
Function that allows complex CQL queries.
See \url{https://api.waterdata.usgs.gov/docs/ogcapi/complex-queries/}
for more information.
}
\examples{
\dontshow{if (is_dataRetrieval_user()) withAutoprint(\{ # examplesIf}

\donttest{
cql <- '{
"op": "and",
"args": [
  {
    "op": "in",
    "args": [
      { "property": "parameter_code" },
      [ "00060", "00065" ]
    ]
  },
 {
    "op": "in",
    "args": [
      { "property": "monitoring_location_id" },
      [ "USGS-07367300", "USGS-03277200" ]
    ]
  }
]
}'

dv_data <- read_waterdata(service = "daily",
                          CQL = cql,
                          time = c("2023-01-01", "2024-01-01"))

# A wildcard in CQL2 is \%
# Here's how to get HUCs that fall within 02070010
cql_huc_wildcard <- '{
"op": "like",
"args": [
  { "property": "hydrologic_unit_code" },
  "02070010\%"
]
}'

what_huc_sites <- read_waterdata(service = "monitoring-locations",
                                 CQL = cql_huc_wildcard)

}
\dontshow{\}) # examplesIf}
}
