Description Usage Arguments Details Value See Also Examples
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.
1 2 3 4 5 6 7 8 9 10 | cellFromRowCol(object, row, col, ...)
cellFromRowColCombine(object, row, col, ...)
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)
|
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 |
duplicates |
Logical. If |
... |
additional arguments (none implemented) |
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
.
vector of row, column or cell numbers. cellFromLine
and cellFromPolygon
return a list, fourCellsFromXY
returns a matrix.
xyFromCell, cellsFromExtent, rowColFromCell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 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)
|
Loading required package: sp
NOTE: rgdal::checkCRSArgs: no proj_defs.dat in PROJ.4 shared files
[1] 45
[1] 1 12
NOTE: rgdal::checkCRSArgs: no proj_defs.dat in PROJ.4 shared files
[1] 1 2 11 12 21 22
NOTE: rgdal::checkCRSArgs: no proj_defs.dat in PROJ.4 shared files
[1] 1 11 21 31 41 51 61 71 81 91
NOTE: rgdal::checkCRSArgs: no proj_defs.dat in PROJ.4 shared files
[1] 1 2 3 4 5 6 7 8 9 10
[1] 6
[1] 5
[1] 46 6
NOTE: rgdal::checkCRSArgs: no proj_defs.dat in PROJ.4 shared files
[,1] [,2] [,3] [,4]
[1,] 46 36 35 45
[2,] 6 16 15 5
NOTE: rgdal::checkCRSArgs: no proj_defs.dat in PROJ.4 shared files
NOTE: rgdal::checkCRSArgs: no proj_defs.dat in PROJ.4 shared files
NOTE: rgdal::checkCRSArgs: no proj_defs.dat in PROJ.4 shared files
NOTE: rgdal::checkCRSArgs: no proj_defs.dat in PROJ.4 shared files
NOTE: rgdal::checkCRSArgs: no proj_defs.dat in PROJ.4 shared files
[[1]]
[1] 51 52 53 61 62 71
[[2]]
[1] 38 48 58
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.