Skip to content

Commit

Permalink
v1.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
rafapereirabr committed Sep 21, 2023
1 parent 8e10d2f commit 4540dde
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 27 deletions.
2 changes: 1 addition & 1 deletion r-package/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: geobr
Title: Download Official Spatial Data Sets of Brazil
Version: 1.8.0
Version: 1.8.1
Authors@R: c(person(given="Rafael H. M.", family="Pereira", email="[email protected]", role=c("aut", "cre"), comment = c(ORCID = "0000-0003-2125-7465")),
person(given="Caio Nogueira", family="Goncalves", role=c("aut")),
person(given="Paulo Henrique Fernandes de", family="Araujo", role=c("ctb")),
Expand Down
8 changes: 7 additions & 1 deletion r-package/NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# geobr v1.8.1

# geobr v1.7.0999 (dev version)
**CRAN request**
- geobr now uses suggested packages conditionally



# geobr v1.8.0

**New function**
- `read_capitals()` to download either a spatial `sf` object with the location of the municipal seats (sede dos municipios) of state capitals, or a `data.frame` with the names of codes of state capitals. [Closes #243](https://github.com/ipeaGIT/geobr/issues/243)
Expand Down
6 changes: 3 additions & 3 deletions r-package/cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
## ── R CMD check results ───────────────────────────────────── geobr 1.8.0 ────
Duration: 8m 3.8s
── R CMD check results ─────────────────────────────────────────────────────────────────────────────── geobr 1.8.1 ────
Duration: 7m 49.9s

❯ checking data for non-ASCII characters ... NOTE
Note: found 58 marked UTF-8 strings

0 errors ✔ | 0 warnings ✔ | 1 note ✖


* Update to version v.1.8.0 with one new function and a few bug fixes.
* geobr now uses suggested packages conditionally

7 changes: 1 addition & 6 deletions r-package/tests/tests_rafa/test_rafa.R
Original file line number Diff line number Diff line change
Expand Up @@ -554,12 +554,7 @@ rhub::check_for_cran(show_status = FALSE)
# submit to CRAN -----------------
usethis::use_cran_comments('teste 2222, , asdadsad')


Sys.setenv(NOT_CRAN = "true")
devtools::submit_cran()



1


# build binary --------------------------------
Expand Down
36 changes: 20 additions & 16 deletions r-package/vignettes/intro_to_geobr.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ knitr::opts_chunk$set(
eval = identical(tolower(Sys.getenv("NOT_CRAN")), "true"),
out.width = "100%"
)
use_suggested_pkgs <- c((requireNamespace("dplyr")),
(requireNamespace("scales")),
(requireNamespace("ggplot2")),
(requireNamespace("censobr")))
use_suggested_pkgs <- all(use_suggested_pkgs)
```


Expand All @@ -36,7 +44,7 @@ devtools::install_github("ipeaGIT/geobr", subdir = "r-package")

Now let's load the libraries we'll use in this vignette.

```{r eval=TRUE, message=FALSE, warning=FALSE, results='hide'}
```{r eval=use_suggested_pkgs, message=FALSE, warning=FALSE, results='hide'}
library(geobr)
library(ggplot2)
library(sf)
Expand All @@ -51,7 +59,7 @@ library(dplyr)

The geobr package covers 27 spatial data sets, including a variety of political-administrative and statistical areas used in Brazil. You can view what data sets are available using the `list_geobr()` function.

```{r eval=TRUE, message=FALSE, warning=FALSE}
```{r eval=use_suggested_pkgs, message=FALSE, warning=FALSE}
# Available data sets
datasets <- list_geobr()
Expand All @@ -65,7 +73,7 @@ head(datasets)
The syntax of all *geobr* functions operate one the same logic, so the code to download the data becomes intuitive for the user. Here are a few examples.

Download an specific geographic area at a given year
```{r eval=TRUE, message=FALSE, warning=FALSE}
```{r eval=use_suggested_pkgs, message=FALSE, warning=FALSE}
# State of Sergige
state <- read_state(
code_state="SE",
Expand Down Expand Up @@ -133,7 +141,7 @@ All functions to download polygon data such as states, municipalities etc. have

Once you've downloaded the data, it is really simple to plot maps using `ggplot2`.

```{r eval=TRUE, message=FALSE, warning=FALSE, fig.height = 8, fig.width = 8, fig.align = "center"}
```{r eval=use_suggested_pkgs, message=FALSE, warning=FALSE, fig.height = 8, fig.width = 8, fig.align = "center"}
# Remove plot axis
no_axis <- theme(axis.title=element_blank(),
axis.text=element_blank(),
Expand All @@ -149,13 +157,10 @@ ggplot() +
```


```{r states br, eval=FALSE, echo=FALSE, message=FALSE, out.width='100%'}
knitr::include_graphics("https://github.com/ipeaGIT/geobr/blob/master/r-package/inst/img/states_br.png?raw=true")
```

Plot all the municipalities of a particular state, such as Rio de Janeiro:

```{r eval=TRUE, message=FALSE, warning=FALSE, fig.height = 8, fig.width = 8, fig.align = "center"}
```{r eval=use_suggested_pkgs, message=FALSE, warning=FALSE, fig.height = 8, fig.width = 8, fig.align = "center"}
# Download all municipalities of Rio
all_muni <- read_municipality(
Expand All @@ -173,9 +178,6 @@ ggplot() +
```

```{r munis rio, eval=FALSE, echo=FALSE, message=FALSE, out.width='100%'}
knitr::include_graphics("https://github.com/ipeaGIT/geobr/blob/master/r-package/inst/img/munis_rj.png?raw=true")
```

## Thematic maps

Expand All @@ -185,7 +187,7 @@ The next step is to combine data from ***geobr*** package with other data sets

First, we need a `data.frame` with estimates of Life Expectancy and merge it to our spatial database. The two-digit abbreviation of state name is our key column to join these two databases.

```{r eval=TRUE, message=FALSE, warning=FALSE, results='hide'}
```{r eval=use_suggested_pkgs, message=FALSE, warning=FALSE, results='hide'}
# Read data.frame with life expectancy data
df <- utils::read.csv(system.file("extdata/br_states_lifexpect2017.csv", package = "geobr"), encoding = "UTF-8")
Expand All @@ -200,7 +202,7 @@ states <- dplyr::left_join(states, df, by = c("name_state" = "uf"))

#### Plot thematic map

```{r eval=TRUE, message=FALSE, warning=FALSE, fig.height = 8, fig.width = 8, fig.align = "center" }
```{r eval=use_suggested_pkgs, message=FALSE, warning=FALSE, fig.height = 8, fig.width = 8, fig.align = "center" }
ggplot() +
geom_sf(data=states, aes(fill=ESPVIDA2017), color= NA, size=.15) +
labs(subtitle="Life Expectancy at birth, Brazilian States, 2014", size=8) +
Expand All @@ -216,7 +218,9 @@ Following the same steps as above, we can use together **geobr** with our sister

First, we need to download households data from the Brazilian census using the `read_households()` function.

```{r, eval = TRUE}


```{r, eval = use_suggested_pkgs }
library(censobr)
hs <- read_households(year = 2010,
Expand All @@ -226,7 +230,7 @@ hs <- read_households(year = 2010,

Now we're going to (a) group observations by municipality, (b) get the number of households connected to a sewage network, (c) calculate the proportion of households connected, and (d) collect the results.

```{r, eval = TRUE, warning = FALSE}
```{r, eval = use_suggested_pkgs, warning = FALSE}
esg <- hs |>
collect() |>
group_by(code_muni) |> # (a)
Expand All @@ -239,7 +243,7 @@ head(esg)
```
Now we only need to download the geometries of Brazilian municipalities from **geobr**, merge the spatial data with our estimates and map the results.

```{r, eval = TRUE, warning = FALSE}
```{r, eval = use_suggested_pkgs, warning = FALSE}
# download municipality geometries
muni_sf <- geobr::read_municipality(year = 2010,
showProgress = FALSE)
Expand Down

0 comments on commit 4540dde

Please sign in to comment.