brclimr

R package to fetch zonal weather indicators for Brazilian municipalities.

https://github.com/rfsaldanha/brclimr

Science Score: 23.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    1 of 2 committers (50.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.9%) to scientific vocabulary
Last synced: 11 months ago · JSON representation

Repository

R package to fetch zonal weather indicators for Brazilian municipalities.

Basic Info
Statistics
  • Stars: 7
  • Watchers: 3
  • Forks: 2
  • Open Issues: 0
  • Releases: 0
Created over 3 years ago · Last pushed over 2 years ago
Metadata Files
Readme Changelog License

README.Rmd

---
output: github_document
---



```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)
```

# brclimr



[![CRAN status](https://www.r-pkg.org/badges/version/brclimr)](https://CRAN.R-project.org/package=brclimr) [![](https://cranlogs.r-pkg.org/badges/brclimr)](https://cran.r-project.org/package=brclimr)
[![R-CMD-check](https://github.com/rfsaldanha/brclimr/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/rfsaldanha/brclimr/actions/workflows/R-CMD-check.yaml)


This R package retrieves zonal statistics from weather indicators that were calculated for each municipality in Brazil using data from the BR-DWGD and TerraClimate projects.

Zonal statistics such as mean, maximum, minimum, standard deviation, and sum were computed by taking into account the data cells that intersect the boundaries of each municipality and stored in Parquet files. This procedure was carried out for all Brazilian municipalities, and for all available dates, for every indicator available in the weather products (BR-DWGD and TerraClimate projects). This package queries on-line the already calculated statistics on the Parquet files and returns easy-to-use data.frames.

Details about the used methodology to calculate the zonal statistics are available at *Articles \> Methodology*.

## Installation

### Stable version

```{r eval=FALSE}
install.packages("brclimr")
```

### Development version

```{r eval=FALSE}
remotes::install_github(repo = "rfsaldanha/brclimr")
```

## Example

To fetch data for a specific product, indicator and statistic, use the `fetch_data` function. For example: Rio de Janeiro, RJ (IBGE code number 3304557), data product "brdwgd", average relative humidity, from 2010-10-15 to 2010-10-20.

```{r}
library(brclimr)

fetch_data(
    code_muni = 3304557,
    product = "brdwgd",
    indicator = "rh",
    statistics = "mean",
    date_start = as.Date("2010-10-15"),
    date_end = as.Date("2010-10-20")
  )
```

If you need to query several municipalities, indicators and zonal statistics, we recommend to download and locally query the parquet files using the `arrow` package. A list of URLs of the parquet files created for this project is available at *Articles \> Parquet files*.

A list with the indicators and zonal statistics available by product can be retrieved with the function `product_info`.

```{r eval=FALSE}
product_info("brdwgd")
product_info("terraclimate")
```

## Another example

```{r}
tmax <- fetch_data(
  code_muni = 3303401,
  product = "brdwgd",
  indicator = "tmax",
  statistics = "mean",
  date_start = as.Date("2010-01-01"),
  date_end = as.Date("2012-01-01")
)

tmin <- fetch_data(
  code_muni = 3303401,
  product = "brdwgd",
  indicator = "tmin",
  statistics = "mean",
  date_start = as.Date("2010-01-01"),
  date_end = as.Date("2012-01-01")
)

pr <- fetch_data(
  code_muni = 3303401,
  product = "brdwgd",
  indicator = "pr",
  statistics = "sum",
  date_start = as.Date("2010-01-01"),
  date_end = as.Date("2012-01-01")
)

tmax$name <- "Tmax_avg"
tmin$name <- "Tmin_avg"
```

```{r}
library(ggplot2)

ggplot(data = rbind(tmax, tmin), aes(x = date, y = value, color = name)) +
  geom_line() +
  scale_x_date(date_breaks = "2 months", date_labels =  "%m/%y") +
  ylim(0, NA) +
  labs(
    title = "Nova Friburgo, RJ",
    x = "Date", 
    y = "Temperature (average)",
    color = ""
  ) +
  theme_bw() +
  theme(legend.position = "bottom", legend.direction = "horizontal")
```

```{r}
ggplot(data = pr, aes(x = date, y = value)) +
  geom_line(color = "blue") +
  scale_x_date(date_breaks = "2 months", date_labels =  "%m/%y") +
  ylim(0, NA) +
  labs(
    title = "Nova Friburgo, RJ",
    x = "Date", 
    y = "Precipitation (sum)",
    color = ""
  ) +
  theme_bw() +
  theme(legend.position = "bottom", legend.direction = "horizontal")
```

Owner

  • Name: Raphael Saldanha
  • Login: rfsaldanha
  • Kind: user
  • Location: Montpellier
  • Company: Inria

Geographer, Master's at Public Health (UFJF), PhD at Health Information and Communication. Postdoc at @INRIA.

GitHub Events

Total
  • Issues event: 1
Last Year
  • Issues event: 1

Committers

Last synced: over 3 years ago

All Time
  • Total Commits: 130
  • Total Committers: 2
  • Avg Commits per committer: 65.0
  • Development Distribution Score (DDS): 0.008
Top Committers
Name Email Commits
Raphael Saldanha r****a@g****m 129
DE FREITAS SALDANHA Raphael r****a@i****r 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: over 1 year ago

All Time
  • Total issues: 3
  • Total pull requests: 5
  • Average time to close issues: 8 months
  • Average time to close pull requests: 6 days
  • Total issue authors: 2
  • Total pull request authors: 2
  • Average comments per issue: 3.67
  • Average comments per pull request: 0.2
  • Merged pull requests: 3
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 3
  • Average time to close issues: N/A
  • Average time to close pull requests: 9 days
  • Issue authors: 0
  • Pull request authors: 2
  • Average comments per issue: 0
  • Average comments per pull request: 0.33
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • rfsaldanha (2)
  • dleonar2 (1)
  • pedrorenanm (1)
Pull Request Authors
  • rfsaldanha (5)
  • nealrichardson (2)
Top Labels
Issue Labels
bug (1)
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • cran 268 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 4
  • Total maintainers: 1
cran.r-project.org: brclimr

Fetch Zonal Statistics of Weather Indicators for Brazilian Municipalities

  • Versions: 4
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 268 Last month
Rankings
Stargazers count: 22.5%
Forks count: 28.8%
Average: 29.6%
Dependent packages count: 29.8%
Downloads: 31.3%
Dependent repos count: 35.5%
Last synced: over 1 year ago

Dependencies

.github/workflows/R-CMD-check.yaml actions
  • actions/checkout v3 composite
  • r-lib/actions/check-r-package v2 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pkgdown.yaml actions
  • JamesIves/github-pages-deploy-action v4.4.1 composite
  • actions/checkout v3 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
DESCRIPTION cran
  • R >= 2.10 depends
  • arrow * imports
  • checkmate * imports
  • dplyr * imports
  • lobstr * imports
  • magrittr * imports
  • rlang * imports
  • spelling * suggests
  • testthat >= 3.0.0 suggests