Search code examples
rsegmentspatstat

How to generate a list of segments from a list of random self-intercepting lines (psp in R)?


I'm using X=rpoisline(4) to generate lines and plot them with plot(X). With X$ends I have their coordinates and their intersection points with selfcrossing.psp(X) (In R with spatstat : library(spatstat)).

I need to get a list of segments and their coordinates and be able to manipulate them (change their orientation, position, intersection...). Those segments have to be defined by the intersection of a line with an other line and with the window.

So, am I missing a simple way to convert a psp of few intersecting lines in a psp of non intersecting segments (I hope it's clear) ?

If you have a non-simple way, I'm interested to !

Thanks for your time !

edit :

Here are the lines I have :

here is what I have

And here are the kind of random stuff I think I can produce if I manage to handle each segments (one by one). So I need to get a list of segments from my list of random lines.

and here is what I need


Solution

  • The spatstat function selfcut.psp is designed for exactly this purpose.

    Y <- selfcut.psp(X)
    

    For further information about manipulating line segment patterns, see section 4.4 in the spatstat book.