Bad map

Day 4 of 30DayMapChallenge
R
30DayMapChallenge
spatial
datavisualization
Author

Michaël

Published

2023-11-04

Modified

2023-11-19

A photo of The Alte Nahebrücke, a medieval stone arch bridge in Bad Kreuznach, in western Germany, dating from around 1300

Bad Kreuznach, Germany – CC-BY-NC by Billy Wilson

Day 4 of 30DayMapChallenge: « Bad map » (previously).

A map of all populated places containing the word “Bad” from Geonames.

library(tidyverse)
library(leaflet)
library(httr)
library(fs)
library(glue)

gn_file <- "~/data/geonames/allCountries.zip"

if (!file_exists(gn_file)) {
  GET("http://download.geonames.org/export/dump/allCountries.zip",
      write_disk(gn_file))
}

gn <- read_delim(
  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"))
bad <- gn |> 
  filter(str_detect(feature_code, "^PPL"),
         str_detect(asciiname, "\\b[Bb]ad\\b"))

bad |> 
  leaflet() |> 
  addCircleMarkers(popup = ~ glue("{name} ({asciiname})<br />
                                  <b>{country_code}</b><br />
                                  {population} inhab.")) |> 
  addTiles(attribution = "Geonames and © OpenStreetMap, ODbL")
Figure 1: Bad map

So we have 471 “Bad” populated places…