如何使用ggplot和ggmap添加道路标签?

时间:2017-12-20 15:38:41

标签: r ggplot2 ggmap

我正在为不同的区域创建地图,并且我设法让几乎所有图层都可以工作,看起来像ArcGIS。我唯一困住的地方是将标签添加到主要道路网络中。我可以正确绘制线条,但形状文件没有特定的x符号,它是开始/结束。由于我无法上传实际形状,因此无法重现代码的道歉

# Load Libraries
library(tidyverse)
library(rgdal)
library(RColorBrewer)
library(ggmap)
library(maptools)
library(rgeos)


# Green-Red Pallete for DAs
pal <- c("#006837", "#1A9850","#66BD63","#A6D96A","#D9EF8B",
         "#FEE08B","#FDAE61","#F46D43","#D73027","#A50026")

# Load Shape Files
Road <-readOGR (dsn = "C:/Users/Shape Files", # dsn = data source name 
                layer = "MajorRoads") # layer = file name

DA_2015 <- readOGR (dsn = "C:/Users/Shape Files",
                    layer = "DisseminationAreas")

# Fortify Shape Files Areas -----------------------------------------------------

DA.f <- DA_2015 %>% fortify (region = "DAUID")%>%
  left_join(DA_2015@data, by=c("id" = "DAUID" )) 

# Create Map -----------------------------------------------------------

map <- ggplot () + 
  geom_path(data = DA.f,
            aes(x = long, y = lat, group = id)) +
  # Add colours to DA
  geom_polygon(data = DA.f,
               aes (x = long, y = lat, group =  id, fill =  csi_bin)) +
  # Add gradient scale to DAscolors
  scale_fill_manual(values = pal)  

RoadLayer <- geom_path (data = Road,
                        aes (x = long, y = lat, group = group), 
                        fill = "grey50", 
                        alpha = 0.5)

map + RoadLayer

enter image description here

如何添加道路标签?

编辑:

以下是我在ArcGIS中执行的地图示例。

enter image description here

0 个答案:

没有答案