在R中绘制省界

Draw province boundaries in R

我想为我的报告绘制等值线图。我已经从 GADM 下载了数据。我成功绘制了等值线图,但是当我添加边界时,出现了错误。出现了很多蓝线。

我的代码是:

#Read Database
HCM <- read.csv("HCM.csv")

#Load Packages
library(plyr)
library(sp)
library(ggplot2)
library(rgeos)
library(maptools)
library(scales)

#Read Map (Map downloaded from GADM)
vie_map1 <- readRDS('VNM_adm1.rds')
vie_map <- fortify(vie_map1, region = "ID_1")

#Draw the map
ggplot() +
  geom_map(data = HCM, aes(map_id = ID, fill = WeightRange), 
           map = vie_map) + expand_limits(x = vie_map$long, y = vie_map$lat)

但是当我想添加边界时,出现了错误(蓝色的直线)。添加边界的代码是:

  # Add the boundaries
 ggplot() +
  geom_map(data = HCM, aes(map_id = ID, fill = WeightRange), 
           map = vie_map) + expand_limits(x = vie_map$long, y = vie_map$lat)+
 geom_path() +
    geom_path(data = vie_map, aes(x = long, y = lat), color = "blue") + 
  theme_bw()

请告诉我如何解决它(删除直线)。

还在geom_path的美学映射中设置group,不仅是xy:

library(ggplot2)
library(raster)
library(maptools)
vie_map1 <- getData("GADM", country="VNM", level=1)
# trying URL 'http://biogeo.ucdavis.edu/data/gadm2.8/rds/VNM_adm1.rds'
# Content type '' length 2765340 bytes (2.6 MB)
# downloaded 2.6 MB
vie_map <- fortify(vie_map1, region = "ID_1")
ggplot() +
  geom_polygon(data = vie_map, aes(x = long, y = lat, group = group), fill = "grey90") +
  geom_path(data = vie_map, aes(x = long, y = lat, group = group), color = "blue") + 
  theme_bw()