I have a shapefile that shows all the roads in Germany. Hereby, I want to create a point at each intersection of lines. Based on this created point, I can split the line into separate line features. Due to high computational power, I created a test shapefile that shows a single-line feature and is characterized by an intersection. The test shapefile is created via ArcGIS Pro. The original shapefile can be obtained via: [Download Free Germany ArcGIS Shapefile Map Layers] ("Germany Roads"). The test shapefile is imported in a simple R-script and visualized:
#necessary libraries
require(sf)
library(sp)
library(tmap)
#import data
intersection <- readOGR('C:/Test/Intersection.shp')
#examine dataset
view(intersection)
#visualize dataset (via tmap)
tm_shape(intersection) +
tm_lines(col = "red")
tm_legend(legend.outside = "TRUE")
The intersection consists of two lines (as one feature) crossing each other.
I have two questions regarding the intersection:
I. How can I create a point feature at the intersection of the line feature?
II. How can I split the single line feature into four different line features? I know that the "Split Line at Point" function is available in ArcGIS Pro, however, I do not know how to translate this function to the context of R.