“Globe”-shaped map of Russia

大兔子大兔子 提交于 2019-12-10 13:27:31

问题


I draw a map of regions of Russia using GADM data:

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

Map I got:

Map I got is too "flat" and doesn't look like map f.e. from Wikipedia. Right and left parts of the map should be turned a bit (as they are due to round shape of the globe).

Map from Wiki:

Is there any way to make it more "globe-shaped"?


回答1:


If you don't mind using ggplot2 you could use coord_map("azequalarea").

Create a data frame:

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

Then plot:

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



来源:https://stackoverflow.com/questions/37566620/globe-shaped-map-of-russia

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!