library(sf)
## Linking to GEOS 3.5.1, GDAL 2.2.1, proj.4 4.9.2
## multipolygon, not the greatest example for real world path data
## but gets the idea
x <- read_sf(system.file("shape/nc.shp", package="sf"))[1:2, ]
library(spbabel)
## basically fortify but in a broader context ...
d <- spbabel::sptable(x)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
## want attributes from x?
d <- inner_join(as_tibble(x) %>%
## put desired x attributes here
dplyr::transmute(NAME, object_ = row_number()),
d)
## Joining, by = "object_"
library(ggplot2)
## note the coordinate attributes are x_, y_, object_, branch_
## which are analogs of gg's x, y, id, group
ggplot(d, aes(x_, y_, group = branch_, colour = NAME)) +
geom_path(arrow = arrow(length=unit(0.30,"cm"), ends="first", type = "closed"))
