# psp

##### Create a Line Segment Pattern

Creates an object of class `"psp"`

representing
a line segment pattern in the two-dimensional plane.

##### Usage

```
psp(x0,y0, x1, y1, window, marks=NULL,
check=spatstat.options("checksegments"))
```

##### Arguments

- x0
Vector of \(x\) coordinates of first endpoint of each segment

- y0
Vector of \(y\) coordinates of first endpoint of each segment

- x1
Vector of \(x\) coordinates of second endpoint of each segment

- y1
Vector of \(y\) coordinates of second endpoint of each segment

- window
window of observation, an object of class

`"owin"`

- marks
(optional) vector or data frame of mark values

- check
Logical value indicating whether to check that the line segments lie inside the window.

##### Details

In the spatstat library, a spatial pattern of line segments is
described by an object of class `"psp"`

. This function
creates such objects.

The vectors `x0`

, `y0`

, `x1`

and `y1`

must be
numeric vectors of equal length. They are interpreted as the cartesian
coordinates of the endpoints of the line segments.

A line segment pattern is assumed to have been observed within a specific
region of the plane called the observation window.
An object of class `"psp"`

representing a point pattern
contains information specifying the observation window.
This window must always be specified when creating a point pattern dataset;
there is intentionally no default action of ``guessing'' the window
dimensions from the data points alone.

The argument `window`

must be an object of class
`"owin"`

. It is a full description of the window geometry,
and could have been obtained from `owin`

or
`as.owin`

, or by just extracting the observation window
of another dataset, or by manipulating such windows.
See `owin`

or the Examples below.

The optional argument `marks`

is given if the line segment pattern
is marked, i.e. if each line segment carries additional information.
For example, line segments which are classified into two or more different
types, or colours, may be regarded as having a mark which identifies
which colour they are.

The object `marks`

must be a vector of the same length
as `x0`

, or a data frame with number of rows equal to the
length of `x0`

. The interpretation is that `marks[i]`

or `marks[i,]`

is the mark attached to the \(i\)th line
segment. If the marks are real numbers then `marks`

should
be a numeric vector, while if the marks takes only a finite number
of possible values (e.g. colours or types) then `marks`

should be a `factor`

.

See `psp.object`

for a description of the class
`"psp"`

.

Users would normally invoke `psp`

to create a line segment pattern,
and the function `as.psp`

to convert data in another
format into a line segment pattern.

##### Value

An object of class `"psp"`

describing a line segment pattern in the two-dimensional plane
(see `psp.object`

).

##### See Also

##### Examples

```
# NOT RUN {
X <- psp(runif(10), runif(10), runif(10), runif(10), window=owin())
m <- data.frame(A=1:10, B=letters[1:10])
X <- psp(runif(10), runif(10), runif(10), runif(10), window=owin(), marks=m)
# }
```

*Documentation reproduced from package spatstat, version 1.59-0, License: GPL (>= 2)*