R将等值线图与绘图坐标结合起来
R combine choropleth plot with plotting coordinates
假设我有两个数据集,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")
如何根据城市数据集将国家级数据的等值线图与点叠加层相结合?
如果我没理解错的话,您可以使用 points
:
向地图添加点
map <- joinCountryData2Map(countries, joinCode = "ISO3", nameJoinColumn = "country")
mapCountryData(map, nameColumnToPlot = "intensity", mapRegion = "Europe")
points(cities$longitude, cities$latitude, col = "black", cex = 1.5)
假设我有两个数据集,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")
如何根据城市数据集将国家级数据的等值线图与点叠加层相结合?
如果我没理解错的话,您可以使用 points
:
map <- joinCountryData2Map(countries, joinCode = "ISO3", nameJoinColumn = "country")
mapCountryData(map, nameColumnToPlot = "intensity", mapRegion = "Europe")
points(cities$longitude, cities$latitude, col = "black", cex = 1.5)