R将等值线图与绘图坐标

时间:2016-10-25 19:17:12

标签: r plot coordinates choropleth

假设我有两个数据集,countriescities

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")

如何根据城市数据集将国家/地区级别数据的等值区域地图与点的叠加结合起来?

1 个答案:

答案 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)