俄罗斯的“球形”地图

8
我使用GADM数据绘制了俄罗斯地区的地图:
setwd("~/Desktop/Master thesis/")
library(sp) 
library(RColorBrewer)
library(raster)

data <- getData('GADM', country='RUS', level=1)
#exclude columns I don't need
data <- data[,-c(2,3,4,5,7,8,9,10,11,12,13)]
data$region <- as.factor(iconv(as.character(data$NAME_1)))
png(file = "~/Desktop/myplot2.png", width = 1300, height = 700, units = "px")
spplot(data, "region", xlim=c(15,190), ylim=c(40,83), col.regions = colorRampPalette(brewer.pal(12, "Set3"))(85), col = "white")  
    dev.off()

我得到的地图: enter image description here

我得到的地图太“平坦”,看起来不像维基百科上的地图。由于地球的圆形,地图的左右两侧应该稍微倾斜。

维基百科上的地图: enter image description here

有没有办法让它更像地球呢?


1
你需要选择正确的投影方式。我会将地图导入到QGIS中,查看哪种投影方式最适合,并在R代码中应用它。 - Roman Luštrik
1个回答

6

如果您不介意使用ggplot2,您可以使用coord_map(“azequalarea”)

创建数据框:

library(ggplot2)
library(maptools)
data.f <- fortify(data, region = "region")

然后绘制图表:
ggplot(data.f) +
  geom_polygon(aes(x = long, y = lat, fill = id, group = group), colour = "white") +
  xlim(15,190) +
  ylim(40,83) +
  coord_map("azequalarea") +
  scale_fill_manual(values = colorRampPalette(brewer.pal(12, "Set3"))(85)) +
  theme(axis.line = element_blank(),
        axis.text.x = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks = element_blank(),
        axis.title.x = element_blank(),
        axis.title.y = element_blank(),
        panel.background = element_blank(),
        panel.border = element_blank(),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        plot.background = element_blank())

enter image description here


绘制地图的主要目的是将地理数据与社会经济指标面板合并,然后根据贫困水平对区域进行着色。 - MariaBee
@MariaBee 那么问题到底出在哪里呢?你可以将数据与另一个数据框(按地区)合并,并根据贫困变量指定填充。 - erc
我理解了你代码的意图。但是在我的情况下,即使直接保存为png文件(就像我的例子一样),从你的代码中绘制一个图形也需要大约15分钟的时间。如果不保存为png文件,它就从未出现过,只是崩溃了。 - MariaBee
@MariaBee 嗯,不幸的是我无法帮助你解决速度/崩溃问题,因为我自己没有遇到过这些问题 :/ - erc

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接