cellFromRowCol(object, rownr, colnr)
cellFromRowColCombine(object, rownr, colnr)
cellFromRow(object, rownr)
cellFromCol(object, colnr)
colFromX(object, x)
rowFromY(object, y)
cellFromXY(object, xy)
cellFromLine(object, lns)
cellFromPolygon(object, p, weights=FALSE)
fourCellsFromXY(object, xy, duplicates=TRUE)
TRUE
, the fraction of each cell that is covered is also returnedTRUE
, 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)cellFromLine
and cellFromPolygon
return a list, fourCellsFromXY
returns a matrix.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
.xyFromCell, cellsFromExtent, rowColFromCell
r <- raster(ncols=10, nrows=10)
cellFromRowCol(r, 5, 5)
cellFromRowCol(r, 1:2, 1:2)
cellFromRowColCombine(r, 1:3, 1:2)
cellFromCol(r, 1)
cellFromRow(r, 1)
colFromX(r, 0.5)
rowFromY(r, 0.5)
cellFromXY(r, cbind(c(0.5,5), c(15, 88)))
fourCellsFromXY(r, cbind(c(0.5,5), c(15, 88)))
cds1 <- rbind(c(-180,-20), c(-160,5), c(-60, 0), c(-160,-60), c(-180,-20))
cds2 <- rbind(c(80,0), c(100,60), c(120,0), c(120,-55), c(80,0))
pols <- SpatialPolygons(list(Polygons(list(Polygon(cds1)), 1), Polygons(list(Polygon(cds2)), 2)))
cellFromPolygon(r, pols)
Run the code above in your browser using DataLab