#### Aula - Elaborando mapas no R #coloque o comando setwd() abaixo ############################################################################# ###### INSTALANDO E CARREGANDO OS PACOTES QUE SERÃO UTILIZADOS ############################################################################# #Tidyverse: Conjunto de pacotes para facilitar a manipulação e visualização de dados no R. # Verifica e instala o pacote tidyverse se necessário if (!require(tidyverse)) { install.packages("tidyverse") library(tidyverse) } #Geobr: Fornece acesso a dados geoespaciais do Brasil, como mapas e informações administrativas. # Verifica e instala o pacote geobr se necessário if (!require(geobr)) { install.packages("geobr") library(geobr) } #Magick: Interface para manipulação avançada de imagens, permitindo editar e processar imagens no R # Verifica e instala o pacote magick se necessário if (!require(magick)) { install.packages("magick") library(magick) } #viridis: Oferece esquemas de cores perceptivamente uniformes e adequados para representação de dados quantitativos # Verifica e instala o pacote viridis se necessário if (!require(viridis)) { install.packages("viridis") library(viridis) } #ggspatial usado para integrar dados espaciais (geoespaciais) em gráficos feitos com ggplot2, permitindo a visualização de informações geográficas em mapas e outras representações visuais. # Verifica e instala o pacote ggspatial se necessário if (!require(ggspatial)) { install.packages("ggspatial") library(ggspatial) } #gridExtra utilizado para organizar e combinar múltiplos gráficos feitos com o ggplot2 em uma única visualização, permitindo criar layouts personalizados com diferentes plots, facilitando a comparação e análise conjunta de múltiplos gráficos. # Verifica e instala o pacote gridExtra se necessário if (!require(gridExtra)) { install.packages("gridExtra") library(gridExtra) } # opção para colcoar escala e símbolo do norte #https://github.com/oswaldosantos/ggsn ############################################################################# ###### VERIFICANDO SE VOCÊ JÁ INFORMOU AO R STUDIO QUAL É O DIRETÓRIO DE TRABALHO QUE ELE IRÁ CONSIDERAR PARA ACESSAR E SALVAR OS SEUS ARQUIVOS ############################################################################# # Ainda na aba “Files”, clique em “ More” (com ícone de engrenagem em azul) e depois em “Set As Working Directory” # Repare: no console, aparecerá o comando “setwd()”. Dentro dos parênteses deverá conter o caminho até a pasta que você escolheu # Para verificar qual o diretório de trabalho está sendo trabalhado, utilize a função: getwd() ############################################################################# ###### LIMPANDO OS OBJETOS DE OUTROS PROJETOS ############################################################################# ls() #Verificando se há objetos usando a função rm(list = ls()) # removendo os objetos ############################################################################# ###### LENDO E PLOTANDO O SHAPE FILE ############################################################################# # Pacote geobr #https://cran.r-project.org/web/packages/geobr/vignettes/intro_to_geobr.html # datasets disponíveis datasets <- list_geobr() str(datasets) #estrutura names(datasets) #nomes das colunas unique(datasets$`function`) #nomes das funções unique(datasets$`geography`) # shps disponíveis #Anos disponíveis para os estados datasets %>% filter(geography == "States") %>% select(years) #datasets[, c("geography", "years")] ############################################################################# #### Treino: Anos disponíveis para as regiões ########################## # Lendo o ano de 2020, para os estados states_shp <- read_state( year = 2020, showProgress = FALSE ) ############################################################################# #### Treino: Ler as regiões para o ano 2018 ########################## # Plotando todas as estados brasileiros ggplot() + geom_sf(data = states_shp) ############################################################################# #### Treino: Plotando todas as regiões brasileiros ########################## ############################################################################# ###### CRIANDO BANCO DE DADOS ############################################################################# ## fake dataset para estados states_df <- data.frame(code_state = c(11, 12, 13, 14, 15, 16, 17, 21, 22, 23, 24, 25, 26, 27, 28, 29, 31, 32, 33, 35, 41, 42, 43, 50, 51, 52, 53), season = c("Summer", "Autumn", "Winter", "Spring"), cod_season = 1:4, year = rep(c(2019, 2020), each = 27 * 4), rate = sample(10:200, size = 216, replace = TRUE)) table(states_df$code_state, states_df$year, states_df$cod_season) # fake dataset para regiões regions_df <- data.frame( code_region = 1:5, name_region = c("Norte", "Nordeste", "Sudeste", "Sul", "Centro Oeste"), season = c("Summer", "Autumn", "Winter", "Spring"), cod_season = 1:4, year = rep(c(2018, 2019), each = 5 * 4), rate = sample(10:200, size = 5 * 4 * 2, replace = TRUE) ) table(regions_df$code_region, regions_df$year, regions_df$cod_season) ############################################################################# ###### UNINDO O MAPA COM A TABELA ############################################################################# states_unido <- left_join(states_shp, states_df, by = "code_state") ############################################################################# #### Treino: Unir as regiões ########################## # conferindo states_unido %>% filter(code_state == 12 & season == "Autumn" & year == 2019) %>% select(rate) states_df %>% filter(code_state == 12 & season == "Autumn" & year == 2019) %>% select(rate) # conferindo states_unido %>% filter(code_state == 35 & season == "Winter" & year == 2020) %>% select(rate) states_df %>% filter(code_state == 35 & season == "Winter" & year == 2020) %>% select(rate) ############################################################################# ###### ELABORANDO MAPAS ############################################################################# #### plotando somente São Paulo states_unido %>% filter(code_state == 35) %>% ggplot() + geom_sf() ############################################################################# ### Variáveis contínuas # Taxa pelo ano de 2020, na estação "verão" states_unido %>% filter(year == 2020 & season == "Summer") %>% ggplot() + geom_sf(aes(fill = rate)) # Borda dos limites das áreas: vermelho states_unido %>% filter(year == 2020 & season == "Summer") %>% ggplot() + geom_sf(aes(fill = rate), colour = "red") # Borda dos limites das áreas: Sem cor states_unido %>% filter(year == 2020 & season == "Summer") %>% ggplot() + geom_sf(aes(fill = rate), colour = NA) # Fundo states_unido %>% filter(year == 2020 & season == "Summer") %>% ggplot() + geom_sf(aes(fill = rate), colour = NA) + theme_classic() # Cores de preenchimento states_unido %>% filter(year == 2020 & season == "Summer") %>% ggplot() + geom_sf(aes(fill = rate), color = NA) + scale_fill_viridis_c() + # Aplicando cores espectrais theme_classic() states_unido %>% filter(year == 2020 & season == "Summer") %>% ggplot() + geom_sf(aes(fill = rate), color = NA) + scale_fill_viridis_c(option = "magma") + # Aplicando cores espectrais, magma theme_classic() states_unido %>% filter(year == 2020 & season == "Summer") %>% ggplot() + geom_sf(aes(fill = rate), color = NA) + scale_fill_gradientn(colors = c("red", "yellow", "green", "blue")) + # Especificando as cores theme_classic() states_unido %>% filter(year == 2020 & season == "Summer") %>% ggplot() + geom_sf(aes(fill = rate), color = NA) + scale_fill_gradientn(colors = c("blue", "green")) + # Especificando as cores theme_classic() states_unido %>% filter(year == 2020 & season == "Summer") %>% ggplot() + geom_sf(aes(fill = rate), color = NA) + scale_fill_distiller(palette = "Spectral") + # Especificando as cores theme_classic() states_unido %>% filter(year == 2020 & season == "Summer") %>% ggplot() + geom_sf(aes(fill = rate), color = NA) + scale_fill_distiller(palette = "Reds") + # Especificando as cores theme_classic() states_unido %>% filter(year == 2020 & season == "Summer") %>% ggplot() + geom_sf(aes(fill = rate), color = NA) + scale_fill_distiller() + # Especificando as cores theme_classic() states_unido %>% filter(year == 2020 & season == "Summer") %>% ggplot() + geom_sf(aes(fill = rate), color = NA) + scale_fill_distiller(palette = "Greys") + # Especificando as cores theme_classic() # Remover os eixos states_unido %>% filter(year == 2020 & season == "Summer") %>% ggplot() + geom_sf(aes(fill = rate), color = NA) + scale_fill_distiller(palette = "Greys") + # Especificando as cores theme_classic() + theme(axis.line = element_blank(), # Remove as linhas dos eixos axis.text = element_blank(), # Remove os rótulos dos eixos #axis.title = element_blank(), # Remove os títulos dos eixos axis.ticks = element_blank()) # Remove as marcações nos eixos # Inclue a escala states_unido %>% filter(year == 2020 & season == "Summer") %>% ggplot() + geom_sf(aes(fill = rate), color = NA) + scale_fill_distiller(palette = "Greys") + # Especificando as cores theme_classic() + theme(axis.line = element_blank(), # Remove as linhas dos eixos axis.text = element_blank(), # Remove os rótulos dos eixos axis.ticks = element_blank()) + # Remove as marcações nos eixos annotation_scale(location = "br") # Inclue o simbolo do norte states_unido %>% filter(year == 2020 & season == "Summer") %>% ggplot() + geom_sf(aes(fill = rate), color = NA) + scale_fill_distiller(palette = "Greys") + # Especificando as cores theme_classic() + theme(axis.line = element_blank(), # Remove as linhas dos eixos axis.text = element_blank(), # Remove os rótulos dos eixos axis.ticks = element_blank()) + # Remove as marcações nos eixos annotation_scale(location = "br" #, #bar_cols = c("grey", "white"), #height = unit(0.5, "cm") ) + annotation_north_arrow(location = "br", which_north = "true", pad_x = unit(.9, "cm"), pad_y = unit(.9, "cm"), style = north_arrow_fancy_orienteering) states_unido %>% filter(year == 2020 & season == "Summer") %>% ggplot() + geom_sf(aes(fill = rate), color = NA) + scale_fill_distiller(palette = "Greys") + # Especificando as cores theme_classic() + theme(axis.line = element_blank(), # Remove as linhas dos eixos axis.text = element_blank(), # Remove os rótulos dos eixos axis.ticks = element_blank()) + # Remove as marcações nos eixos annotation_scale(location = "br") + annotation_north_arrow(location = "br", which_north = "true", pad_x = unit(.9, "cm"), pad_y = unit(.9, "cm"), style = north_arrow_minimal) states_unido %>% filter(year == 2020 & season == "Summer") %>% ggplot() + geom_sf(aes(fill = rate), color = NA) + scale_fill_distiller(palette = "Greys") + # Especificando as cores theme_classic() + theme(axis.line = element_blank(), # Remove as linhas dos eixos axis.text = element_blank(), # Remove os rótulos dos eixos axis.ticks = element_blank()) + # Remove as marcações nos eixos annotation_scale(location = "br") + annotation_north_arrow(location = "br", which_north = "true", pad_x = unit(.9, "cm"), pad_y = unit(.9, "cm"), style = north_arrow_nautical) # Mais opções: #https://search.r-project.org/CRAN/refmans/ggspatial/html/north_arrow_orienteering.html ### Título da legenda states_unido %>% filter(year == 2020 & season == "Summer") %>% ggplot() + geom_sf(aes(fill = rate), color = NA) + scale_fill_distiller(name = "Taxa", palette = "Greys") + # Especificando as cores theme_classic() + theme( axis.line = element_blank(), # Remove as linhas dos eixos axis.text = element_blank(), # Remove os rótulos dos eixos axis.ticks = element_blank(), # Remove as marcações nos eixos legend.title = element_text(size = 18, face = "bold"), # Título da legenda legend.text = element_text(size = 14), # Tamanho do texto da legenda legend.key.width = unit(1, "cm") # Largura dos elementos da legenda ) + annotation_scale(location = "br") + annotation_north_arrow( location = "br", which_north = "true", pad_x = unit(.9, "cm"), pad_y = unit(.9, "cm"), style = north_arrow_nautical ) # Legenda do preenchimento: opções states_unido %>% filter(year == 2020 & season == "Summer") %>% ggplot() + geom_sf(aes(fill = rate), color = NA) + scale_fill_distiller(name = "Taxa", palette = "Greys") + # Especificando as cores theme_classic() + theme( axis.line = element_blank(), # Remove as linhas dos eixos axis.text = element_blank(), # Remove os rótulos dos eixos axis.ticks = element_blank(), # Remove as marcações nos eixos legend.title = element_text(size = 18, face = "bold"), # Título da legenda legend.text = element_text(size = 14), # Tamanho do texto da legenda legend.key.width = unit(1, "cm"), # Largura dos elementos da legenda legend.position = "bottom" # Posição da legenda ) + annotation_scale(location = "br") + annotation_north_arrow( location = "br", which_north = "true", pad_x = unit(.9, "cm"), pad_y = unit(.9, "cm"), style = north_arrow_nautical ) states_unido %>% filter(year == 2020 & season == "Summer") %>% ggplot() + geom_sf(aes(fill = rate), color = NA) + scale_fill_distiller(name = "Taxa", palette = "Greys") + # Especificando as cores theme_classic() + theme( axis.line = element_blank(), # Remove as linhas dos eixos axis.text = element_blank(), # Remove os rótulos dos eixos axis.title = element_blank(), # Remove os títulos dos eixos axis.ticks = element_blank(), # Remove as marcações nos eixos legend.title = element_text(size = 18, face = "bold"), # Título da legenda legend.text = element_text(size = 14), # Tamanho do texto da legenda legend.key.width = unit(1, "cm"), # Largura dos elementos da legenda legend.position = "top" # Posição da legenda ) + annotation_scale(location = "br") + annotation_north_arrow( location = "br", which_north = "true", pad_x = unit(.9, "cm"), pad_y = unit(.9, "cm"), style = north_arrow_nautical ) states_unido %>% filter(year == 2020 & season == "Summer") %>% ggplot() + geom_sf(aes(fill = rate), color = NA) + scale_fill_distiller(name = "Taxa", palette = "Greys") + # Especificando as cores theme_classic() + theme( axis.line = element_blank(), # Remove as linhas dos eixos axis.text = element_blank(), # Remove os rótulos dos eixos axis.title = element_blank(), # Remove os títulos dos eixos axis.ticks = element_blank(), # Remove as marcações nos eixos legend.title = element_text(size = 18, face = "bold"), # Título da legenda legend.text = element_text(size = 14), # Tamanho do texto da legenda legend.key.width = unit(1, "cm"), # Largura dos elementos da legenda legend.position = "left" # Posição da legenda ) + annotation_scale(location = "br") + annotation_north_arrow( location = "br", which_north = "true", pad_x = unit(.9, "cm"), pad_y = unit(.9, "cm"), style = north_arrow_nautical ) ### JUstificado states_unido %>% filter(year == 2020 & season == "Summer") %>% ggplot() + geom_sf(aes(fill = rate), color = NA) + scale_fill_distiller(name = "Taxa", palette = "Greys") + # Especificando as cores theme_classic() + theme( axis.line = element_blank(), # Remove as linhas dos eixos axis.text = element_blank(), # Remove os rótulos dos eixos axis.ticks = element_blank(), # Remove as marcações nos eixos legend.title = element_text(size = 18, face = "bold"), # Título da legenda legend.text = element_text(size = 14), # Tamanho do texto da legenda legend.key.width = unit(1, "cm"), # Largura dos elementos da legenda legend.justification = c(0, 0) # Justificação da legenda (x, y) ) + annotation_scale(location = "br") + annotation_north_arrow( location = "br", which_north = "true", pad_x = unit(.9, "cm"), pad_y = unit(.9, "cm"), style = north_arrow_nautical ) # Posição da legenda states_unido %>% filter(year == 2020 & season == "Summer") %>% ggplot() + geom_sf(aes(fill = rate), color = NA) + scale_fill_distiller(name = "Taxa", palette = "Greys") + # Especificando as cores theme_classic() + theme( axis.line = element_blank(), # Remove as linhas dos eixos axis.text = element_blank(), # Remove os rótulos dos eixos axis.ticks = element_blank(), # Remove as marcações nos eixos legend.title = element_text(size = 18, face = "bold"), # Título da legenda legend.text = element_text(size = 14), # Tamanho do texto da legenda legend.key.width = unit(1, "cm"), # Largura dos elementos da legenda legend.position = c(0.8, 0.2), # Posição da legenda legend.justification = c(0, 0) # Justificação da legenda (x, y) ) + annotation_scale(location = "br") + annotation_north_arrow( location = "br", which_north = "true", pad_x = unit(.9, "cm"), pad_y = unit(.9, "cm"), style = north_arrow_nautical ) states_unido %>% filter(year == 2020 & season == "Summer") %>% ggplot() + geom_sf(aes(fill = rate), color = NA) + scale_fill_distiller(name = "Taxa", palette = "Greys") + # Especificando as cores theme_classic() + theme( axis.line = element_blank(), # Remove as linhas dos eixos axis.text = element_blank(), # Remove os rótulos dos eixos axis.ticks = element_blank(), # Remove as marcações nos eixos legend.title = element_text(size = 18, face = "bold"), # Título da legenda legend.text = element_text(size = 14), # Tamanho do texto da legenda legend.key.width = unit(1, "cm"), # Largura dos elementos da legenda legend.position = c(0.8, 0.2) # Posição da legenda ) + annotation_scale(location = "br") + annotation_north_arrow( location = "br", which_north = "true", pad_x = unit(.9, "cm"), pad_y = unit(.9, "cm"), style = north_arrow_nautical ) ############################################################################# ###### MÚLTIPLOS MAPAS ############################################################################# range(states_unido$rate) # amplitude da taxa plot_2019 <- states_unido %>% filter(year == 2019 & season == "Summer") %>% ggplot() + geom_sf(aes(fill = rate), color = NA, show.legend = F) + ### tirar a legenda scale_fill_distiller(name = "Taxa", palette = "Greys", limits = c(10, 200)) + # Especificando as cores theme_classic() + theme( axis.line = element_blank(), # Remove as linhas dos eixos axis.text = element_blank(), # Remove os rótulos dos eixos axis.ticks = element_blank(), # Remove as marcações nos eixos # legend.title = element_text(size = 12, face = "bold"), # Título da legenda # legend.text = element_text(size = 10), # Tamanho do texto da legenda # legend.key.width = unit(1, "cm"), # Largura dos elementos da legenda # legend.position = c(0.8, 0.2) # Posição da legenda ) + annotation_scale(location = "br") + labs(title = "2019", size = 30) + ## Texto annotation_north_arrow( location = "br", which_north = "true", pad_x = unit(.9, "cm"), pad_y = unit(.9, "cm"), style = north_arrow_nautical ) plot_2020 <- states_unido %>% filter(year == 2020 & season == "Summer") %>% ggplot() + geom_sf(aes(fill = rate), color = NA, show.legend = T) + scale_fill_distiller(name = "Taxa", palette = "Greys", limits = c(10, 200)) + # Especificando as cores theme_classic() + theme( axis.line = element_blank(), # Remove as linhas dos eixos axis.text = element_blank(), # Remove os rótulos dos eixos axis.ticks = element_blank(), # Remove as marcações nos eixos legend.title = element_text(size = 20, face = "bold"), # Título da legenda legend.text = element_text(size = 14), # Tamanho do texto da legenda legend.key.width = unit(0.5, "cm"), # Largura dos elementos da legenda legend.position = c(0.8, 0.2) # Posição da legenda ) + #annotation_scale(location = "br") + labs(title = "2020", size = 30) # + # annotation_north_arrow( # location = "br", # which_north = "true", # pad_x = unit(.9, "cm"), # pad_y = unit(.9, "cm"), # style = north_arrow_nautical #) # Abre o dispositivo de saída TIFF tiff("mapa_por_ano.tiff", width = 35, height = 17, units = "cm", res = 300, # compression = "lzw" ) grid.arrange( plot_2019, plot_2020, ncol = 2) dev.off() ## outros formatos jpeg("mapa_por_ano.jpeg", width = 35, height = 17, units = "cm", res = 300, # compression = "lzw" ) grid.arrange( plot_2019, plot_2020, ncol = 2) dev.off() # Loop para criar os mapas para cada estação e atribuir a objetos separados for (season in c("Summer", "Spring", "Winter", "Autumn")) { # Filtra os dados para a estação atual no loop current_plot <- states_unido %>% filter(year == 2020 & season == season) %>% ggplot() + geom_sf(aes(fill = rate), color = NA) + scale_fill_distiller(name = "Taxa", palette = "Spectral", limits = c(10, 200)) + # Especificando as cores theme_classic() + theme( axis.line = element_blank(), # Remove as linhas dos eixos axis.text = element_blank(), # Remove os rótulos dos eixos axis.title = element_blank(), # Remove os títulos dos eixos axis.ticks = element_blank(), # Remove as marcações nos eixos legend.title = element_text(size = 9, face = "bold"), # Título da legenda legend.text = element_text(size = 6), # Tamanho do texto da legenda legend.key.width = unit(0.2, "cm"), # Largura dos elementos da legenda legend.position = c(0.9, 0.4) # Posição da legenda ) + labs(title = season) + annotation_scale(location = "br") + annotation_north_arrow( location = "br", which_north = "true", pad_x = unit(1.2, "cm"), pad_y = unit(.8, "cm"), style = north_arrow_nautical ) # Atribui o gráfico atual a um objeto separado com o nome da estação assign(paste0(season, "_plot"), current_plot) } grid.arrange( Summer_plot, Spring_plot, Winter_plot, Autumn_plot, ncol = 2) ############################################################################# ###### MAPA CATEGÓRICO ############################################################################# ################### CRIANDO CTEGORIAS SEGUNDO QUANTIL quantile(states_unido$rate) # quantil em 4 categorias quantile(states_unido$rate, prob = seq(0, 1, 1/4)) # quantil em 4 categorias quantile(states_unido$rate, prob = seq(0, 1, 1/5)) # quantil em 5 categorias states_unido$quantil <- NA states_unido$quantil[states_unido$rate < 49] <- "0-48" states_unido$quantil[states_unido$rate >= 49 & states_unido$rate < 99] <- "49-98" states_unido$quantil[states_unido$rate >= 99 & states_unido$rate < 148] <- "99-147" states_unido$quantil[states_unido$rate >= 148] <- "148 ou mais" table(states_unido$quantil, useNA = "always") # conferência, faz uma tabela de valores por categoria e mostra os valores NA # Transformando em factor e reordenando os níveis states_unido$quantil <- factor(states_unido$quantil, levels = c("0-48", "49-98", "99-147", "148 ou mais")) # Verifique os níveis atuais levels(states_unido$quantil) ###### MAPAS # table(states_unido$quantil, states_unido$season, states_unido$year) # conferência, faz uma tabela de valores por categoria e mostra os valores NA # Suponha que você tem uma paleta de cores para cada nível cores <- c("0-48" = "#fee5d9", "49-98" = "#fcae91", "99-147" = "#fb6a4a", "148 ou mais" = "#cb181d") plot_2019_cat <- states_unido %>% filter(year == 2019 & season == "Summer") %>% ggplot() + geom_sf(aes(fill = quantil), color = NA, show.legend = F) + scale_fill_manual(values = cores) + # Especificando as cores theme_classic() + theme( axis.line = element_blank(), # Remove as linhas dos eixos axis.text = element_blank(), # Remove os rótulos dos eixos axis.title = element_blank(), # Remove os títulos dos eixos axis.ticks = element_blank(), # Remove as marcações nos eixos # legend.title = element_text(size = 12, face = "bold"), # Título da legenda # legend.text = element_text(size = 10), # Tamanho do texto da legenda # legend.key.width = unit(1, "cm"), # Largura dos elementos da legenda # legend.position = c(0.8, 0.2) # Posição da legenda ) + annotation_scale(location = "br") + labs(title = "2019") + annotation_north_arrow( location = "br", which_north = "true", pad_x = unit(.9, "cm"), pad_y = unit(.9, "cm"), style = north_arrow_nautical ) plot_2020_cat <- states_unido %>% filter(year == 2020 & season == "Summer") %>% ggplot() + geom_sf(aes(fill = quantil), color = NA, show.legend = T) + scale_fill_manual(name = "Taxa", values = cores) + # Especificando as cores theme_classic() + theme( axis.line = element_blank(), # Remove as linhas dos eixos axis.text = element_blank(), # Remove os rótulos dos eixos axis.title = element_blank(), # Remove os títulos dos eixos axis.ticks = element_blank(), # Remove as marcações nos eixos legend.title = element_text(size = 14, face = "bold"), # Título da legenda legend.text = element_text(size = 12), # Tamanho do texto da legenda legend.key.width = unit(0.5, "cm"), # Largura dos elementos da legenda legend.position = c(0.82, 0.2) # Posição da legenda ) + #annotation_scale(location = "br") + labs(title = "2020") # + # annotation_north_arrow( # location = "br", # which_north = "true", # pad_x = unit(.9, "cm"), # pad_y = unit(.9, "cm"), # style = north_arrow_nautical #) getwd() # Abre o dispositivo de saída TIFF tiff("mapa_por_ano_categorias.tiff", width = 35, height = 17, units = "cm", res = 300, compression = "lzw") grid.arrange( plot_2019_cat, plot_2020_cat, ncol = 2) dev.off() ############################################################################# #### Treino: Elaboro um múltiplos mapas segundo regiões em escala de cores laranjas ##########################