as.data.frame.owin: Convert Window to Data Frame

View source: R/window.R

as.data.frame.owinR Documentation

Convert Window to Data Frame

Description

Converts a window object to a data frame.

Usage

## S3 method for class 'owin'
as.data.frame(x, ..., drop=TRUE)

Arguments

x

Window (object of class "owin").

...

Further arguments passed to as.data.frame.default to determine the row names and other features.

drop

Logical value indicating whether to discard pixels that are outside the window, when x is a binary mask.

Details

This function returns a data frame specifying the coordinates of the window.

If x is a binary mask window, the result is a data frame with columns x and y containing the spatial coordinates of each pixel. If drop=TRUE (the default), only pixels inside the window are retained. If drop=FALSE, all pixels are retained, and the data frame has an extra column inside containing the logical value of each pixel (TRUE for pixels inside the window, FALSE for outside).

If x is a rectangle or a polygonal window, the result is a data frame with columns x and y containing the spatial coordinates of the vertices of the window. If the boundary consists of several polygons, the data frame has additional columns id, identifying which polygon is being traced, and sign, indicating whether the polygon is an outer or inner boundary (sign=1 and sign=-1 respectively).

Value

A data frame with columns named x and y, and possibly other columns.

Author(s)

\spatstatAuthors

.

See Also

as.data.frame.im, as.owin.data.frame

Examples

   as.data.frame(square(1))

   holey <- owin(poly=list(
                        list(x=c(0,10,0), y=c(0,0,10)),
                        list(x=c(2,2,4,4), y=c(2,4,4,2))))
   as.data.frame(holey)

   M <- as.mask(holey, eps=0.5)
   Mdf <- as.data.frame(M)

spatstat.geom documentation built on March 29, 2022, 9:06 a.m.