cellsFromExtent: Cells from extent, and vice versa

Description Usage Arguments Value See Also Examples

Description

cellsFromExtent returns the cell numbers for a Raster* object that are within a specfied extent (rectangular area), supply an object of class Extent, or another Raster* object.

extentFromCells returns an Extent object from a Raster* object and cell numbers. All cells are within the returned Extent.

Usage

1
2
cellsFromExtent(object, extent, expand=FALSE)
extentFromCells(object, cells)

Arguments

object

A Raster* object

extent

An object of class Extent (which you can create with newExtent(), or another Raster* object )

expand

Logical. If TRUE, NA is returned for (virtual) cells implied by bndbox, that are outside the RasterLayer (object). If FALSE, only cell numbers for the area where object and bndbox overlap are returned (see intersect)

cells

numeric. A vector of cell numbers

Value

a vector of cell numbers

See Also

extent, cellFromXY

Examples

1
2
3
4
5
6
7
r <- raster()
bb <- extent(-5, 5, -5, 5)
cells <- cellsFromExtent(r, bb)
r <- crop(r, bb)
r[] <- cells

e <- extentFromCells(r, 50:55)

miraisolutions/raster documentation built on May 30, 2019, 11:41 p.m.