This file contains hidden or 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
#lendo o dataset no formato de um dataframe através da função read do pandas | |
dataset = pd.read_csv('winequality-red.csv', sep=';') #realiza a leitura do banco de dados |
This file contains hidden or 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
<iframe id="github-iframe2" src="" style="width:100%;height:450px"></iframe> | |
<script> | |
fetch('https://api.github.com/repos/dpavancini/covid19/contents/map_100k.html?ref=master') | |
.then(function(response) { | |
return response.json(); | |
}).then(function(data) { | |
iframe = document.getElementById('github-iframe2'); | |
iframe.src = 'data:text/html;base64,' + encodeURIComponent(data['content']); | |
}); | |
</script> |
This file contains hidden or 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
#Exportando mapas | |
htmlwidgets::saveWidget(map_100k,"map_100k.html") |
This file contains hidden or 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
## define cores para cada conjunto numérico | |
pal <- colorNumeric(palette = "Reds", domain = shp_sf$confirmed_per_100k_inhabitants) | |
# heatmap dos casos de covid-19, por 100 mil habitantes, em SC. | |
map_100k <- leaflet(shp_sf) %>% | |
addProviderTiles(providers$CartoDB.Positron) %>% | |
addPolygons(data = shp_sf, | |
smoothFactor = 0.5, | |
fillOpacity = 0.5, | |
weight = 0.5, |
This file contains hidden or 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
# bibliotecas | |
library(brazilmaps) | |
library(sf) | |
# pegando as geometrias das cidades de Santa Catarina (42) | |
shp <- get_brmap("City", geo.filter = list(State = 42)) | |
shp$City <- as.character(shp$City) | |
# definindo que o dataframe contém dados geométricos | |
shp_sf <- st_as_sf(shp)%>% | |
st_transform(4326) |
This file contains hidden or 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
map_total_cases <- leaflet(data_covid19) %>% addTiles() %>% | |
addProviderTiles(providers$CartoDB.Positron) %>% | |
addCircleMarkers( | |
radius = ~sqrt(data_covid19$confirmed), | |
fillOpacity = 0.5, stroke = F, | |
popup = paste0("<b>Cidade: </b>", data_covid19$city,"<br>", | |
"<b>Casos Confirmados: </b>", data_covid19$confirmed), | |
label = ~city | |
) |
This file contains hidden or 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
## bibliotecas | |
library(leaflet) | |
map_cities <- leaflet(data_covid19) %>% | |
addTiles() %>% | |
addMarkers(popup = paste0("<b>Cidade: </b>", data_covid19$city,"<br>", | |
"<b>Casos Confirmados: </b>", data_covid19$confirmed), | |
label = ~city | |
group = "addMarkers") %>% | |
addCircleMarkers(popup = paste0("<b>Cidade: </b>", data_covid19$city,"<br>", |
This file contains hidden or 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
# Primeiro precisamos dos dados de latitude e longitude das cidades analisadas. | |
urlfile <- "https://raw.githubusercontent.com/kelvins/Municipios-Brasileiros/master/csv/municipios.csv" | |
cities_lat_lng <- read.csv(urlfile,encoding = "UTF-8", col.names = c("COD_IBGE", "Cidade","lat","lng","Capital","Codigo_UF")) | |
# é necessário se certificar que o código de cada cidade estará em formato de texto, para o que a função left_join funcione. | |
cities_lat_lng$COD_IBGE <- as.character(cities_lat_lng$COD_IBGE) | |
data_covid19 <- left_join(data_covid19, cities_lat_lng, by = c("city_ibge_code" = "COD_IBGE")) |
This file contains hidden or 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
## bibliotecas | |
library(httr) | |
library(jsonlite) | |
library(dplyr) | |
## api para pegar os dados mais atualizados de Covid-19 | |
read_CityDataCovid <- function() { | |
# lê a URL da api | |
url <- "https://brasil.io/api/dataset/covid19/caso/data?format=json" | |
tf <- GET(url) |