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"?
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())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With