the following code chunks produce a simple leaflet map. The points represent the most prominent cities in the world and the data is taken from here (free): http://simplemaps.com/data/world-cities
The data set contains around ~7300 entries. The paid version - including all cities around 3.9 Mio - was out of my budget.
(files_loc <- list.files("./", full.names = TRUE))
[1] "./fr.csv"
[2] "./Leaflet.html"
[3] "./Leaflet.rmd"
[4] "./rsconnect"
[5] "./simplemaps-worldcities-basic.csv"
data <- read.csv("./simplemaps-worldcities-basic.csv")
head(data); dim(data)
city city_ascii lat lng pop country iso2 iso3
1 Qal eh-ye Now Qal eh-ye 34.9830 63.1333 2997 Afghanistan AF AFG
2 Chaghcharan Chaghcharan 34.5167 65.2500 15000 Afghanistan AF AFG
3 Lashkar Gah Lashkar Gah 31.5830 64.3600 201546 Afghanistan AF AFG
4 Zaranj Zaranj 31.1120 61.8870 49851 Afghanistan AF AFG
5 Tarin Kowt Tarin Kowt 32.6333 65.8667 10000 Afghanistan AF AFG
6 Zareh Sharan Zareh Sharan 32.8500 68.4167 13737 Afghanistan AF AFG
province
1 Badghis
2 Ghor
3 Hilmand
4 Nimroz
5 Uruzgan
6 Paktika
[1] 7322 9require(leaflet)
data %>%
leaflet() %>%
addTiles() %>%
setView(lng = 40, lat = 40, zoom = 3) %>%
addCircles(weight = 1, radius = sqrt(data$pop) * 90, color = "black")(files_loc <- list.files("./", full.names = TRUE))
[1] "./fr.csv"
[2] "./Leaflet.html"
[3] "./Leaflet.rmd"
[4] "./rsconnect"
[5] "./simplemaps-worldcities-basic.csv"
dataFR <- read.csv("./fr.csv")
head(dataFR); dim(dataFR)
city city_ascii lat lng country iso2 iso3
1 Valette Valette 45.28333 2.600000 France FR FRA
2 Valette Valette 45.63978 1.163670 France FR FRA
3 Valette Valette 45.86058 0.840478 France FR FRA
4 Valette Valette 46.23173 1.898168 France FR FRA
5 Valette Valette 49.05107 6.842641 France FR FRA
6 Valeuil Valeuil 45.33327 0.617953 France FR FRA
admin admin_code admin_type capital density population
1 Auvergne-Rhône-Alpes FR-ARA region 16.7 NA
2 Nouvelle-Aquitaine FR-NAQ region 41.2 NA
3 Nouvelle-Aquitaine FR-NAQ region 115.5 NA
4 Nouvelle-Aquitaine FR-NAQ region 63.9 NA
5 Grand Est FR-GES region 78.6 NA
6 Nouvelle-Aquitaine FR-NAQ region 23.0 NA
id
1 1250764594
2 1250052127
3 1250774138
4 1250019285
5 1250872386
6 1250820799
[1] 57809 14The mentioned homepage does provide the complete data set, but only for the state France.
require(leaflet)
dataFR <- dataFR[which(dataFR$population>0), ]; dim(dataFR)
#> [1] 56 14
dataFR %>%
leaflet() %>%
addTiles() %>%
addCircles(weight = 1, radius = sqrt(dataFR$population) * 90, color = "black")