spatstat (version 1.53-2)

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

Description

Converts a window object to a data frame.

Usage

# S3 method for 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.

Value

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

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).

See Also

as.data.frame.im

Examples

Run this code
# NOT RUN {
   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)
# }

Run the code above in your browser using DataCamp Workspace