---
title: "Methodology"
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```

The objective of this project is to retrieve data from datasets of statistics of weather variables for Brazilian municipalities. These datasets were created by using zonal statistics.

Zonal statistics are descriptive statistics calculated using a set of cells that spatially intersects a given spatial boundary. For each boundary in a map, statistics like average, maximum value, minimum value, standard deviation, and sum are obtained to represent the cell's values that intersect the boundary.

The Brazilian municipality boundaries from 2010 were used as a reference, as provided by the `{geobr}` package.

Thus, for each municipality, a set of zonal statistics of weather indicators is calculated, at the same time resolution of the source dataset.

![](zonal_statistics.png)

Those datasets are available as parquet files on S3 buckets and queried by this project functions to retrieve data for a given municipality, dates, weather indicators, and desired zonal statistics.

## Source datasets

### BR-DWGD

> Xavier, A. C., Scanlon, B. R., King, C. W., & Alves, A. I. (2022). New improved Brazilian daily weather gridded data (1961--2020). International Journal of Climatology. <https://doi.org/10.1002/joc.7731>

The BR-DWGD dataset presents daily meteorological data interpolated to a grid with 0.1° $\times$ 0.1° of spatial resolution for the Brazilian territory, with daily data from January 1, 1961, to July 31, 2020. It used data from 1,252 weather stations and 11,473 rain gauges in its interpolation methods, cross-validated to the selection of the best method for each weather indicator.

The following weather indicators are available from the BR-DWGD study: precipitation (mm), minimum temperature (°C) maximum temperature (°C), solar radiation ($MJ\cdot m^{-2}$), wind speed at 2m height ($m\cdot s^{-1}$) and relative humidity (%).

The function `product_info` present the available weather indicators, acronyms, units, zonal statistics, time unit, and coverage available.

```{r brdwgd_info}
library(brclimr)

product_info(product = "brdwgd")
```

### TerraClimate

> Abatzoglou, J. T., Dobrowski, S. Z., Parks, S. A., Hegewisch, K. C. (2018). TerraClimate, a high-resolution global dataset of monthly climate and climatic water balance from 1958-2015. Scientific Data, 5. https://doi.org/10.1038/sdata.2017.191</div>

The monthly data from TerraClimate is being processed and will be included soon in this package.
