Description Usage Arguments Details Value Examples
Get cell number(s) of a Raster* object from polygon objects.
1 | cellFromPolygon(object, p, weights = FALSE)
|
object |
Raster* object (or a SpatialPixels* or SpatialGrid* object) |
p |
sf (polygon or mutlipolygon) or SpatialPolygons object |
weights |
Logical. If TRUE, the fraction of each cell that is covered is also returned |
See cellFrom
for more details.
a list of cell numbers
1 2 3 4 5 6 | x <- read_sf(system.file("shape/nc.shp", package="sf"))
pcells <- cellFromPolygon(raster(x, res = 0.1), x[1:4, ])
pcells0 <- list(c(27, 28, 29, 30, 116, 117, 118, 119, 120, 206, 207, 208,
296), c(31, 32, 33, 34, 121, 122, 123), c(35, 36, 37, 38, 39,
124, 125, 126, 127, 128, 213, 214, 215, 216, 217, 302), c(81,
82, 83, 84, 85, 171, 172, 262, 352))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.