假设我有两个数据集,countries
和cities
:
set.seed(42)
countries <- data.frame(country = c("DEU", "FRA", "ITA", "POL"),
intensity = abs(rnorm(4)))
cities <- data.frame(city = c("Berlin", "Paris", "Roma", "Warszawa"),
longitude = c(13.408333, 2.351667, 12.483333, 21.033333),
latitude = c(52.518611, 48.856667, 41.883333, 52.216667))
countries
描述了强度的国家级数据集。 cities
是包含坐标的数据集。到目前为止,我已使用rworldmap
绘制强度:
library(rworldmap)
map <- joinCountryData2Map(countries, joinCode = "ISO3", nameJoinColumn = "country")
mapCountryData(map, nameColumnToPlot = "intensity", mapRegion = "Europe")
如何根据城市数据集将国家/地区级别数据的等值区域地图与点的叠加结合起来?
答案 0 :(得分:1)
如果我理解正确,您可以使用points
map <- joinCountryData2Map(countries, joinCode = "ISO3", nameJoinColumn = "country")
mapCountryData(map, nameColumnToPlot = "intensity", mapRegion = "Europe")
points(cities$longitude, cities$latitude, col = "black", cex = 1.5)