% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/get_brdwgd.R
\name{get_brdwgd}
\alias{get_brdwgd}
\title{Fetch BR-DWGD Data for Multiple Locations}
\usage{
get_brdwgd(
  data,
  days_around,
  date_col,
  study_col = "study",
  path = "netcdf_files",
  vars = c("pr", "Tmax", "Tmin", "Rs", "RH"),
  direction = "both"
)
}
\arguments{
\item{data}{A data frame containing the input data, including columns for \code{latitude}, \code{longitude},
and the date column specified by \code{date_col}.}

\item{days_around}{An integer specifying the number of days before and after the date in the date column
to download data.}

\item{date_col}{A character string specifying the name of the date column in the data frame.}

\item{study_col}{A character string specifying the name of the column containing the study identifier
in the input data frame (default: "study").}

\item{path}{A character string specifying the directory where the BR-DWGD NetCDF files are stored.}

\item{vars}{A character vector specifying the weather variables to fetch.
These are expected to be the prefix of the NetCDF files (e.g., "pr", "Tmax").
Default: \code{c("pr", "Tmax", "Tmin", "Rs", "RH")}.}

\item{direction}{Character string specifying the direction of the date range relative to the reference date.
Options are "both" (default), "back", or "forth".
"back" retrieves data from \code{date - days_around} to \code{date}.
"forth" retrieves data from \code{date} to \code{date + days_around}.
"both" retrieves data from \code{date - days_around} to \code{date + days_around}.}
}
\value{
A data frame (tibble) with daily weather data. Columns are named to match
\code{nasapower} conventions where possible: \code{date}, \code{PRECTOTCORR} (from \code{pr}),
\code{T2M_MAX} (from \code{Tmax}), \code{T2M_MIN} (from \code{Tmin}), \code{ALLSKY_SFC_SW_DWN} (from \code{Rs}),
\code{RH2M} (from \code{RH}), \code{longitude}, \code{latitude}, and \code{study}.
}
\description{
This function extracts daily weather data from the Brazilian Daily Weather Gridded Data (BR-DWGD)
NetCDF files for specified locations and dates. It mimics the functionality of \code{get_nasapower}
and \code{get_era5} by returning a daily-aggregated data frame with columns named according
to \code{nasapower} conventions.
}
\details{
The function requires the \code{terra} package to read NetCDF files and the \code{tidyr} package
for data reshaping. It expects NetCDF files to be named starting with the variable name
(e.g., \code{pr_*.nc}) and to contain the variable with the same name.
}
\seealso{
Other Disease modeling: 
\code{\link{get_era5}()},
\code{\link{get_nasapower}()},
\code{\link{windowpane}()}
}
\concept{Disease modeling}
