Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

raster.x

Cartesian Coordinates for a Pixel Raster


Description

Return the x and y coordinates of each pixel in a pixel image or binary mask.

Usage

raster.x(w, drop=FALSE)
 raster.y(w, drop=FALSE)
 raster.xy(w, drop=FALSE)

Arguments

w

A pixel image (object of class "im") or a mask window (object of class "owin" of type "mask").

drop

Logical. If TRUE, then coordinates of pixels that lie outside the window are removed. If FALSE (the default) then the coordinates of every pixel in the containing rectangle are retained.

Details

The argument w should be either a pixel image (object of class "im") or a mask window (an object of class "owin" of type "mask").

If drop=FALSE (the default), the functions raster.x and raster.y return a matrix of the same dimensions as the pixel image or mask itself, with entries giving the x coordinate (for raster.x) or y coordinate (for raster.y) of each pixel in the pixel grid.

If drop=TRUE, pixels that lie outside the window w (or outside the domain of the image w) are removed, and raster.x and raster.y return numeric vectors containing the coordinates of the pixels that are inside the window w.

The function raster.xy returns a list with components x and y which are numeric vectors of equal length containing the pixel coordinates.

Value

raster.xy returns a list with components x and y which are numeric vectors of equal length containing the pixel coordinates.

If drop=FALSE, raster.x and raster.y return a matrix of the same dimensions as the pixel grid in w, and giving the value of the x (or y) coordinate of each pixel in the raster.

If drop=TRUE, raster.x and raster.y return numeric vectors.

Author(s)

and Ege Rubak rubak@math.aau.dk

See Also

Examples

u <- owin(c(-1,1),c(-1,1)) # square of side 2
  w <- as.mask(u, eps=0.01) # 200 x 200 grid
  X <- raster.x(w)
  Y <- raster.y(w)
  disc <- owin(c(-1,1), c(-1,1), mask=(X^2 + Y^2 <= 1))
  # plot(disc)
  # approximation to the unit disc

spatstat.geom

Geometrical Functionality of the 'spatstat' Family

v2.1-0
GPL (>= 2)
Authors
Adrian Baddeley [aut, cre], Rolf Turner [aut], Ege Rubak [aut], Tilman Davies [ctb], Ute Hahn [ctb], Abdollah Jalilian [ctb], Sebastian Meyer [ctb], Suman Rakshit [ctb], Dominic Schuhmacher [ctb], Rasmus Waagepetersen [ctb]
Initial release
2021-04-15

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.