俄罗斯的阴谋一分为二
Plot of Russia split in two
我正在尝试从 shp 文件中绘制俄罗斯,但俄罗斯总是分成两部分出现。我如何让俄罗斯重新团结起来?
我尝试了几个 shp 文件,例如
http://www.naturalearthdata.com/downloads/10m-cultural-vectors/
Admin 1 – 州、省;下载无大湖 (14.11 MB) 版本 3.0.0
shp <- readOGR("ne_10m_admin_1_states_provinces_lakes.shp")
子集到俄罗斯
names(shp)
rus <- shp[shp$admin == "Russia" , ]
x11()
plot(rus)
既然要画图,可以将shapefile强化为data frame,修改-180区域的经度坐标,将结果画在ggplot
:
library(rgdal); library(ggplot2)
# read in the shapefile & subset to Russia
shp <- readOGR(dsn = "ne_10m", layer = "ne_10m_admin_1_states_provinces_lakes")
rus <- shp[shp$admin == "Russia", ]
# fortify to data frame & modify longitude coordinates in the -180 region.
rus.fortify <- fortify(rus) %>%
mutate(long = ifelse(long < -100, long + 180*2, long))
# plot to verify
ggplot(rus.fortify,
aes(x = long, y = lat, group = group)) +
geom_polygon(fill = "white", col = "black") +
coord_map() #default projection is mercator
我刚刚还从 了解到您可以指定不同的投影系统。鉴于俄罗斯有多大,这应该是相关的:
ggplot(rus.fortify,
aes(x = long, y = lat, group = group)) +
geom_polygon(fill = "white", col = "black") +
coord_map("azequalarea")
我正在尝试从 shp 文件中绘制俄罗斯,但俄罗斯总是分成两部分出现。我如何让俄罗斯重新团结起来?
我尝试了几个 shp 文件,例如 http://www.naturalearthdata.com/downloads/10m-cultural-vectors/ Admin 1 – 州、省;下载无大湖 (14.11 MB) 版本 3.0.0
shp <- readOGR("ne_10m_admin_1_states_provinces_lakes.shp")
子集到俄罗斯
names(shp)
rus <- shp[shp$admin == "Russia" , ]
x11()
plot(rus)
既然要画图,可以将shapefile强化为data frame,修改-180区域的经度坐标,将结果画在ggplot
:
library(rgdal); library(ggplot2)
# read in the shapefile & subset to Russia
shp <- readOGR(dsn = "ne_10m", layer = "ne_10m_admin_1_states_provinces_lakes")
rus <- shp[shp$admin == "Russia", ]
# fortify to data frame & modify longitude coordinates in the -180 region.
rus.fortify <- fortify(rus) %>%
mutate(long = ifelse(long < -100, long + 180*2, long))
# plot to verify
ggplot(rus.fortify,
aes(x = long, y = lat, group = group)) +
geom_polygon(fill = "white", col = "black") +
coord_map() #default projection is mercator
我刚刚还从
ggplot(rus.fortify,
aes(x = long, y = lat, group = group)) +
geom_polygon(fill = "white", col = "black") +
coord_map("azequalarea")