Created
August 3, 2022 13:03
-
-
Save rfsaldanha/e8bb8bee653759852832be58465cb134 to your computer and use it in GitHub Desktop.
Exemplo de mapa utilizando as bibliotecas ggplot2 e geobr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Pacotes | |
library(tidyverse) | |
# remotes::install_github("ipeaGIT/geobr", subdir = "r-package") | |
library(geobr) | |
# Dados | |
df_simu_curso_orig <- read.csv('https://drive.google.com/uc?export=download&id=17ZmUSdC0G4S1OUBpqUzllXqPlOLP1pVD') | |
# Mapa | |
uf_mapa <- read_municipality() | |
res <- df_simu_curso_orig %>% | |
filter(uf == "RJ", ano == 2015) %>% | |
mutate(taxa = total_mortes/população*100000) %>% | |
select(cod_ibge, taxa) %>% | |
na.omit() | |
res2 <- inner_join(res, uf_mapa, by = c("cod_ibge" = "code_muni")) | |
ggplot(data = res2) + | |
geom_sf(aes(geometry = geom, fill = taxa)) + | |
scale_fill_distiller(palette = "Reds", direction = 1, name="Taxa") + | |
theme_minimal() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment