library(tidyverse)
library(leaflet)
library(httr)
library(fs)
library(glue)
Day 19 of 30DayMapChallenge: « 5-minute map » (previously).
Setup
Data
We reuse the Geonames data from Bad map.
<- "~/data/geonames/allCountries.zip"
gn_file
if (!file_exists(gn_file)) {
GET("http://download.geonames.org/export/dump/allCountries.zip",
write_disk(gn_file))
}
<- read_delim(
gn
gn_file, delim = "\t",
col_names = c("geonameid",
"name",
"asciiname",
"alternatenames",
"latitude",
"longitude",
"feature_class",
"feature_code",
"country_code",
"cc2",
"admin1_code",
"admin2_code",
"admin3_code",
"admin4_code",
"population",
"elevation",
"dem",
"timezone",
"modification_date"))
We randomly keep five places containing “minute”…
set.seed(5555)
<- gn |>
minute filter(str_detect(asciiname, "\\b[Mm]inutes?\\b")) |>
slice_sample(n = 5)
Map
|>
minute leaflet() |>
addCircleMarkers(popup = ~ glue("{name} ({asciiname})<br />
<b>{country_code}</b>"),
label = ~ asciiname,
labelOptions = labelOptions(noHide = TRUE)) |>
addTiles(attribution = "Geonames and © OpenStreetMap, ODbL")
And it just took five minutes to do…