rasterFromCells

0th

Percentile

Subset a raster by cell numbers

This function returns a new raster based on an existing raster and cell numbers for that raster. The new raster is cropped to the cell numbers provided, and, if values=TRUE has values that are the cell numbers of the original raster.

Keywords
spatial
Usage
rasterFromCells(x, cells, values=TRUE)
Arguments
x

Raster* object (or a SpatialPixels* or SpatialGrid* object)

cells

vector of cell numbers

values

Logical. If TRUE, the new RasterLayer has cell values that correspond to the cell numbers of x

Details

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.

Value

RasterLayer

See Also

rowFromCell

Aliases
  • rasterFromCells
Examples
# NOT RUN {
r <- raster(ncols=100, nrows=100)
cells <- c(3:5, 210)
r <- rasterFromCells(r, cells)
cbind(1:ncell(r), getValues(r))
# }
Documentation reproduced from package raster, version 2.9-5, License: GPL (>= 3)

Community examples

Looks like there are no examples yet.