An open API service indexing awesome lists of open source software.

https://github.com/openwashdata/wsabrazil

This dataset about wastewater management and household infrastructure from various Brazilian regions provides insights into wastewater disposal habits, water sources, bathroom facilities, and sanitation infrastructure.
https://github.com/openwashdata/wsabrazil

2010 brazil infrastructure open-data r sanitation wash wastewater water

Last synced: 4 months ago
JSON representation

This dataset about wastewater management and household infrastructure from various Brazilian regions provides insights into wastewater disposal habits, water sources, bathroom facilities, and sanitation infrastructure.

Awesome Lists containing this project

README

          

---
output: github_document
always_allow_html: true
editor_options:
markdown:
wrap: 72
chunk_output_type: console
bibliography: references.bib
---

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

library(tidyverse)
```

# wsabrazil

[![License: CC BY 4.0](https://img.shields.io/badge/License-CC_BY_4.0-darkorange.svg)](https://creativecommons.org/licenses/by/4.0/)
[![R-CMD-check](https://github.com/openwashdata/wsabrazil/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/openwashdata/wsabrazil/actions/workflows/R-CMD-check.yaml)

This package contains information related to wastewater management practices and household infrastructure in Brazil. It includes variables such as sector codes, metropolitan region names, municipality codes, and names, as well as data on the location type, living conditions, average income, and household amenities. The data provides insights into wastewater disposal habits, water supply sources, bathroom facilities, and sanitation infrastructure in Brazilian households, contributing to understanding environmental sustainability and infrastructure development efforts. @atlas
![](man/figures/Rplot04.png)
Based on the data, it appears for example that most of the municipalities exhibits poor housing conditions. In this dataset, housing conditions are represented numerically, with '1' indicating correct housing conditions and '0' indicating poor housing conditions. The location map displays all Brazilian municipalities from which data has been collected.

## Installation

You can install the development version of wsabrazil from [GitHub](https://github.com/) with:

```r
# install.packages("devtools")
devtools::install_github("openwashdata/wsabrazil")
```

Alternatively, you can download the dataset as a CSV or XLSX
file from the table below.

```{r, echo=FALSE, message=FALSE, warning=FALSE}

extdata_path <- "https://github.com/openwashdata/wsabrazil/raw/main/inst/extdata/"

read_csv("data-raw/dictionary.csv") |>
distinct(file_name) |>
dplyr::mutate(file_name = str_remove(file_name, ".rda")) |>
dplyr::rename(dataset = file_name) |>
mutate(
CSV = paste0("[Download CSV](", extdata_path, dataset, ".csv)"),
XLSX = paste0("[Download XLSX](", extdata_path, dataset, ".xlsx)")
) |>
knitr::kable()

```

## Data

The dataset includes observations of wastewater management practices and household infrastructure (access to water and sanitation services) across various regions in Brazil.

The package provides access to one single dataset.

```{r, echo = TRUE}
library(wsabrazil)
```

The `wsabrazil` dataset has `r ncol(wsabrazil)`
variables and `r nrow(wsabrazil)` observations. For an overview
of the variable names, see the following table.

```{r, eval=FALSE}
wsabrazil
```

```{r, echo=FALSE, message=FALSE, warning=FALSE}
readr::read_csv("data-raw/dictionary.csv") |>
dplyr::filter(file_name == "wsabrazil.rda") |>
dplyr::select(variable_name:description) |>
knitr::kable() |>
kableExtra::kable_styling() |>
kableExtra::scroll_box(height = "400px")
```

## Examples

### 1. Housing conditions across municipalities

The location map displayed above was created as follows:

```{r eval=FALSE, message=FALSE, warning=FALSE, include=TRUE, paged.print=FALSE}
library(wsabrazil)
library(ggplot2)
library(sf)
library(dplyr)

shapefile <- st_read("man/gadm41_BRA_2.json")
merged_data <- merge(shapefile, wsabrazil, by.x = "CC_2", by.y = "municipality_code")

# Plot the choropleth map
ggplot() +
geom_sf(data = merged_data, aes(fill = as.factor(sector_type))) +
scale_fill_manual(name = "sector_type", values = c("0" = "#E69F00", "1" = "#0072B2"),
labels = c("0" = "poor", "1" = "correct")) +
labs(title = "Housing conditions across municipalities") +
theme(plot.title = element_text(hjust = 0.5, face = "bold", color = "#333333", size = 24),
legend.title = element_text(face = "bold", color = "#333333", size = 16),
legend.text = element_text(color = "#333333", size = 16))
```

### 2. Water supply in Brazil

From the dataset, we can also explore the distribution of water sources in the whole country. We create here a horizontal bar plot to visualize the frequency of different water sources available, utilizing variables such as piped water or stored rainwater. We observe from the resulting plot (see Figure below) that the majority of private households are supplied by piped water. Interestingly, almost none of the households store rainwater. This is possibly due to factors such as local climate patterns and infrastructure limitations.

```{r, eval=FALSE}
library(dplyr)
library(ggplot2)
library(wsabrazil)
library(tidyr)

data_long_summary <- wsabrazil |>
pivot_longer(cols = piped_water:other_water_source,
names_to = "water_source",
values_to = "frequency") |>
group_by(water_source) |>
summarise(total_frequency = sum(frequency, na.rm = TRUE)) |>
arrange(total_frequency)

# Create a horizontal bar plot of water source types
plot <- ggplot(data_long_summary, aes(x = total_frequency, y = reorder(water_source, total_frequency))) +
geom_col(fill = "#0072B2") +
labs(x = "Frequency", y = "Water Source",
title = "Water supply in Brazil",
caption = "") +
theme(plot.title = element_text(hjust = 0.5, face = "bold", color = "#333333"))

plot + scale_x_continuous(labels = scales::number_format())

```

![](man/figures/Rplot01.png)

## License

Data are available as
[CC-BY](https://github.com/openwashdata/wsabrazil/LICENSE.md).

## Citation

To cite this package, please use:

```{r}
citation("wsabrazil")
```

## References

```{html, echo = FALSE}


```