俄罗斯的情节分为两部分

时间:2017-09-04 05:38:03

标签: r plot shapefile

我试图用一个shp文件来描绘俄罗斯,但俄罗斯总是分两部分出现。我如何将俄罗斯重新组合在一起?

我尝试了几个shp文件,例如 http://www.naturalearthdata.com/downloads/10m-cultural-vectors/ 管理员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)

enter image description here

1 个答案:

答案 0 :(得分:3)

由于你想绘制它,你可以将shapefile强化为数据框,修改-180区域中的经度坐标,&amp;将结果绘制在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

plot1: default mercator projection

我刚从this post学到了你可以指定不同的投影系统。鉴于俄罗斯有多大,这应该是相关的:

ggplot(rus.fortify,
       aes(x = long, y = lat, group = group)) +
  geom_polygon(fill = "white", col = "black") +
  coord_map("azequalarea")

plot2: equal area projection