Get cell number(s) of a Raster* object from row and/or column numbers. Cell numbers start at 1 in the upper left corner, and increase from left to right, and then from top to bottom. The last cell number equals the number of cells of the Raster* object.
object: Raster* object (or a SpatialPixels* or SpatialGrid* object)
colnr: column number; or vector of column numbers
rownr: row number; or vector of row numbers
col: column number; or vector of column numbers
row: row number; or vector of row numbers
x: x coordinate(s)
y: y coordinate(s)
xy: matrix of x and y coordinates, or a SpatialPoints or SpatialPointsDataFrame object
lns: SpatialLines object
p: SpatialPolygons object
weights: Logical. If TRUE, the fraction of each cell that is covered is also returned
duplicates: Logical. If TRUE, the same cell number can be returned twice (if the point in the middle of a division between two cells) or four times (if a point is in the center of a cell)
...: additional arguments (none implemented)
Details
cellFromRowCol returns the cell numbers obtained for each row / col number pair. In contrast, cellFromRowColCombine returns the cell numbers obtained by the combination of all row and column numbers supplied as arguments.
fourCellsFromXY returns the four cells that are nearest to a point (if the point falls on the raster). Also see adjacent.
Returns
vector of row, column or cell numbers. cellFromLine and cellFromPolygon return a list, fourCellsFromXY returns a matrix.