cellFromPolygon: Get cell number from polygons

Description Usage Arguments Details Value Examples

Description

Get cell number(s) of a Raster* object from polygon objects.

Usage

1

Arguments

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

Details

See cellFrom for more details.

Value

a list of cell numbers

Examples

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))

mdsumner/sfraster documentation built on May 12, 2019, 1:05 p.m.