对于由...制作的数据帧 fortify 要正常工作,行必须按原来的顺序排列,否则你会得到你在北加拿大看到的那种奇怪的效果。如果我要进行任何合并并加入它,我想向强化对象添加行ID。所以:
fortify
shapefile <- readOGR("[path to shape file]", "Canada") shapefile_df <- fortify(shapefile, region = "NAME") shapefile_df$row_id <- 1:nrow(shapefile_df)
然后重命名变量并进行连接等,在绘制它之前:
shapfile_df <- shapefile_df %>% arrange(row_id)