We start by loading tidyverse
package to manipulate with data and then load the package itself.
library(tidyverse)
library(sf)
library(CzechData)
library(leaflet)
library(RColorBrewer)
library(htmlwidgets)
library(rmapshaper)
id_okresy_Brno <- okresy %>%
filter(str_detect(nazev, "Brno")) %>%
pull(lau1_kod)
obce_obce <- obce %>%
filter(lau1_kod %in% id_okresy_Brno) %>%
datatable(options = list(scrollX = TRUE))
# saveWidget(obce_obce, file = "tabulka.html", selfcontained = FALSE)
volebni_okrsky <- load_RUIAN_settlement(id_obec, layer = "volebni okrsky")
#> ℹ Downloading data.
#> ✔ Data unpacked.
volebni_okrsky <- volebni_okrsky %>%
select(cislo) %>%
st_transform(4326)
volebni_okrsky <- ms_simplify(volebni_okrsky, keep = 0.1)
names(st_geometry(volebni_okrsky)) <- NULL
labels <- sprintf("<strong>%s</strong>", volebni_okrsky$cislo) %>%
lapply(htmltools::HTML)
l <- leaflet(data = volebni_okrsky, width = "100%") %>%
addTiles() %>%
addPolygons(fillColor = brewer.pal(8, "Set2"), fillOpacity = 0.4,
stroke = TRUE, weight = 0.5, color = "black",
highlight = highlightOptions(weight = 3,
bringToFront = TRUE),
label = labels)
# saveWidget(l, file = "mapa.html", selfcontained = FALSE)