Skip to contents

# Fetch zonal statistics

Source: `R/fetch_data.R`
`fetch_data.Rd`

Fetch zonal statistics from a product for given municipality code and dates.

## Usage

    fetch_data(code_muni, product, indicator, statistics, date_start, date_end)

## Arguments

code_muni

  numeric. IBGE municipality code number with 7 digits.

product

  string. Zonal indicator product. Options are: `brdwgd`, `terraclimate`.

indicator

  string. Indicator name from the product. Check the available indicators with the product_info function.

statistics

  string. Statistics name from the indicator. Check the available statistics with the product_info function.

date_start

  date, included in the selection.

date_end

  date, included in the selection, must be equal or greater than `date_start`.

## Value

A `data.frame` with date and value columns.

## Details

For products with monthly data, like `terraclimate`, inform the start and end dates with the fist day of the month. Example: `as.Date("2008-06-01")` for June, 2008.

## Examples

    # \donttest{
    fetch_data(
        code_muni = 3304557,
        product = "brdwgd",
        indicator = "tmax",
        statistics = "mean",
        date_start = as.Date("2008-01-01"),
        date_end = as.Date("2008-01-10")
     )
    #>          date    value
    #> 1  2008-01-01 32.30699
    #> 2  2008-01-02 32.46510
    #> 3  2008-01-03 35.87420
    #> 4  2008-01-04 36.78043
    #> 5  2008-01-05 31.33866
    #> 6  2008-01-06 27.75847
    #> 7  2008-01-07 26.01266
    #> 8  2008-01-08 29.52877
    #> 9  2008-01-09 29.21746
    #> 10 2008-01-10 31.05568
     # }