nearest.raster.point {spatstat}R Documentation

Find Pixel Nearest to a Given Point

Description

Given cartesian coordinates, find the nearest pixel.

Usage

 nearest.raster.point(x,y,w)

Arguments

x Numeric vector of x coordinates of any points
y Numeric vector of y coordinates of any points
w A window (an object of class "owin") of type "mask" representing a binary pixel image.

Details

The argument w should be a window (an object of class "owin", see owin.object for details). A window of type "mask" represents a binary pixel image.

This function returns a list containing two vectors rr and cc giving row and column positions (in the image matrix). For the location (x[i],y[i]) the nearest pixel is at row rr[i] and column cc[i] of the image.

Value

List containing two vectors rr and cc giving row and column positions (in the image matrix).

Author(s)

Adrian Baddeley adrian@maths.uwa.edu.au http://www.maths.uwa.edu.au/~adrian/ and Rolf Turner rolf@math.unb.ca http://www.math.unb.ca/~rolf

See Also

owin.object, as.mask

Examples

  w <- owin(c(0,1), c(0,1), mask=matrix(TRUE, 100,100))  # 100 x 100 grid
  nearest.raster.point(0.5, 0.3, w)

[Package spatstat version 1.6-5 Index]