# as.owin

From spatstat v1.13-4
by Adrian Baddeley

##### Convert Data To Class owin

Converts data specifying an observation window
in any of several formats, into an object of class `"owin"`

.

##### Usage

```
as.owin(W, ..., fatal=TRUE)
## S3 method for class 'owin':
as.owin(W, \dots, fatal=TRUE)
## S3 method for class 'ppp':
as.owin(W, \dots, fatal=TRUE)
## S3 method for class 'ppm':
as.owin(W, \dots, fatal=TRUE)
## S3 method for class 'quad':
as.owin(W, \dots, fatal=TRUE)
## S3 method for class 'im':
as.owin(W, \dots, fatal=TRUE)
## S3 method for class 'gpc.poly':
as.owin(W, \dots, fatal=TRUE)
## S3 method for class 'default':
as.owin(W, \dots, fatal=TRUE)
```

##### Arguments

- W
- Data specifying an observation window, in any of several formats
described under
*Details*below. - fatal
- Logical flag determining what to do if the data cannot be converted to an observation window. See Details.
- ...
- Ignored.

##### Details

The class `"owin"`

is a way of specifying the observation window
for a point pattern. See `owin.object`

for an overview.
This function converts data in any of several formats
into an object of class `"owin"`

for use by the `W`

may be

- an object of class
`"owin"`

- a structure with entries
`xrange`

,`yrange`

specifying the$x$and$y$dimensions of a rectangle - a four-element vector
(interpreted as
`(xmin, xmax, ymin, ymax)`

) specifying the$x$and$y$dimensions of a rectangle - a structure with entries
`xl`

,`xu`

,`yl`

,`yu`

specifying the$x$and$y$dimensions of a rectangle as`(xmin, xmax) = (xl, xu)`

and`(ymin, ymax) = (yl, yu)`

. This will accept objects of class`spp`

used in the Venables and Ripleyspatial library. - an object of class
`"gpc.poly"`

from thegpclib package, representing a polygonal window. - an object of class
`"ppp"`

representing a point pattern. In this case, the object's`window`

structure will be extracted. - an object of class
`"quad"`

representing a quadrature scheme. In this case, the window of the`data`

component will be extracted. - an object of class
`"im"`

representing a pixel image. In this case, a window of type`"mask"`

will be returned, with the same pixel raster coordinates as the image. An image pixel value of`NA`

, signifying that the pixel lies outside the window, is transformed into the logical value`FALSE`

, which is the corresponding convention for window masks. - an object of class
`"ppm"`

representing a fitted point process model. In this case,`as.owin`

extracts the original point pattern data to which the model was fitted, and returns the observation window of this point pattern.

`W`

is not in one of these formats
and cannot be converted to a window, then an error will
be generated (if `fatal=TRUE`

) or a value of `NULL`

will be returned (if `fatal=FALSE`

). The function `as.owin`

is generic, with methods for
`"owin"`

,
`"im"`

and
`"ppp"`

as well as the default method.

##### Value

- An object of class
`"owin"`

(see`owin.object`

) specifying an observation window.

##### See Also

##### Examples

```
w <- as.owin(c(0,1,0,1))
w <- as.owin(list(xrange=c(0,5),yrange=c(0,10)))
# point pattern
data(demopat)
w <- as.owin(demopat)
# image
Z <- as.im(function(x,y) { x + 3}, unit.square())
w <- as.owin(Z)
# Venables & Ripley 'spatial' package
require(spatial)
towns <- ppinit("towns.dat")
w <- as.owin(towns)
detach(package:spatial)
```

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

### Community examples

Looks like there are no examples yet.