Skip to content
Prev 26265 / 29559 Next

Splitting spatial lines at self intersections (line crossings)

The `psp` class in spatstat consists of individual line segments and 
`selfcrossing.psp` checks whether each individual line intersects one of 
the other lines, which happens at all the points in your plot.

If instead you treat each of the two line sequences as a `psp` you can 
check find the crossings of the two `psp` objects. I.e., continuing your 
code (with `spatstat` and `maptools` loaded):

L1 <- SpatialLines(list(Lines(list(Line(pts)), "X")))
L2 <- SpatialLines(list(Lines(list(Line(pt2)), "X")))
l1 <- as.psp(L1)
l2 <- as.psp(L2)
int <- crossing.psp(l1, l2)

This gives you the four intersections between the lines. I don't know of 
a simple way to do the next task in `spatstat`. A useful function if you 
are going to try to write some code is `test.crossing.psp` which gives 
you a logical matrix indicating which segments cross.

Cheers,
Ege
On 01/25/2018 11:26 PM, Glenn Stauffer wrote: