Mapa Covid municípios do RS
library(sf)
library(geobr)
library(tidyverse)
library(colorspace)
library(gganimate)
library(gifski)
library(leaflet)
casosRS <- read.csv("C:/Users/user/Desktop/Vida acadêmica/Disciplinas/Estágio docente/SIG/covid19_rs.csv")
casosRS <- casosRS[-c(499), ]
casosRS <- casosRS[, -c(1,2,4,7)]
rs <- read_municipality(code_muni = "RS", year = 2018, showProgress = F)
rs <- rs[-c(1,2), ]
rs <- rs[, -c(3,4)]
rsCasosCovid <- merge(rs, casosRS, by.x = "code_muni", by.y = "city_ibge_code")
map <- leaflet(rsCasosCovid) %>% addTiles()
bins <- c(0, 10, 20, 50 , 100, 200, 500, 1000, Inf)
pal <- colorBin("YlOrRd", domain = rsCasosCovid$deaths, bins = bins)
label <- sprintf("<strong>%s</strong></br>%g Confirmados</br>%g Óbitos",
rsCasosCovid$name_muni, rsCasosCovid$confirmed, rsCasosCovid$deaths) %>%
lapply(htmltools::HTML)
mapa <- map %>% addPolygons(fillColor = ~pal(deaths),
weight = 1,
opacity = 1,
color = "white",
dashArray = '1',
fillOpacity = 0.7,
highlight = highlightOptions(
weight = 5,
color = "#666",
dashArray = "",
fillOpacity = 0.7,
bringToFront = T),
label = label,
labelOptions = labelOptions(
style = list("font-weight" = "normal", padding = "3px 8px"),
textsize = "15px",
direction = "auto"))
addLegend(mapa, pal = pal, values = ~deaths,
opacity = 0.7, title = "Óbitos RS",
position = "bottomright")