## Reinitialized the REmap setting
remap.init()
## Get world city geocode from simplemaps.com
## https://simplemaps.com/data/world-cities
geodata <- readr::read_csv('data/worldcities.csv') |>
dplyr::filter(capital == 'primary') |>
dplyr::select(lng, lat, country, city) |>
dplyr::rename(lon = lng)
countries <- geodata$country |>
unique()
## randomly set country codes
data = data.frame(country = countries, value = 5 * sample(length(countries)) + 200)
## cities
vec <- geodata$city
## lon & lat of cities
geodata <- geodata |>
data.frame() |>
dplyr::select(lon, lat, city) |>
dplyr::rename(vec = city)
## Design a line data frame
markLinedata = data.frame(origin = rep('Beijing', (length(vec) - 1)), destination = geodata$vec[!geodata$vec %in% 'Beijing'])
## Plot the REmap shining
wmap <- remapC(data, maptype = 'world',
color = c('black', 'black'),
theme = get_theme(backgroundColor = 'black'),
markPointData = vec, markLineData = markLinedata,
geoData = geodata)
knitrREmap(wmap, local = FALSE)
参考文献:https://rpubs.com/chiffon_9797/worldmap