我正在尝试在 R 中制作地图以显示英国每个地区的出现次数。
我的数据目前如下所示:
Area Occurences lon lat
1 Greater London East North UK 200 -0.0936496 51.43092
2 Lambeth and Southwark UK 16 -0.1178424 51.49351
3 Black Country UK 58 -2.0752861 52.52005
4 Glasgow UK 45 -4.2518060 55.86424
5 Leeds UK 331 -1.5490774 53.80076
6 Sth Herts or Watford UK 210 -0.3903200 51.65649
我有所有 120 个观测值的经度和纬度。到目前为止,我已使用以下代码尝试生成图表:
library(rgdal)
library(cartogram)
library(tmap)
library(maptools)
ukgrid = "+init=epsg:27700"
data(wrld_simpl)
afr <- wrld_simpl[wrld_simpl$NAME == "United Kingdom",]
afr <- spTransform(afr, CRS(ukgrid))
# construct cartogram
afrc <- cartogram(afr, "POP2005", itermax=5)
# plot it
tm_shape(afrc) + tm_fill("POP2005", style="jenks") +
tm_borders() + tm_layout(frame=F)
这会生成英国地图,但我不确定如何将我自己的数据用于制图,而不是使用地图所基于的“wrld_simpl”数据中的人口数据。
有没有人有这样做的经验或知道另一种方法来达到预期的结果?谢谢!