library(ggplot2)
library(tidyverse)
library(patchwork)
library(sf)
#> Linking to GEOS 3.6.1, GDAL 2.2.3, proj.4 4.9.3
nc <- sf::st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE)
nc_12 <- tibble::rownames_to_column(nc[1:2,], "id")
nc_12_merged <- nc_12 %>%
st_boundary() %>%
st_union() %>%
st_line_merge() %>%
st_sf()
nc_12_casted <- sf::st_cast(nc_12, "MULTILINESTRING")
p1 <- ggplot(nc_12_casted) +
geom_sf(colour = "black", fill = "transparent", linetype = "11", size = 4) +
theme_minimal() +
ggtitle("casted")
p2 <- ggplot(nc_12_merged) +
geom_sf(colour = "black", fill = "transparent", linetype = "11", size = 4) +
theme_minimal() +
ggtitle("merged")
p1 / p2
Created on 2018-06-05 by the reprex package (v0.2.0).