Learn R Programming

raster (version 1.9-41)

crop: Crop

Description

crop returns a geographic subset of the input Raster* object as specified by an Extent object (or object from which an extent object can be extracted/created). Areas in the bounding box outside of the intput RasterLayer are ignored, and the Extent is aligned to the cells of the input RasterLayer.

Usage

crop(x, y, ...)

Arguments

x
A Raster* object
y
Extent object, or any object from which an Extent object can be extracted (see Details)
...
Additional arguments as for writeRaster

Value

  • Raster* object

Details

Objects that have a Extent object include RasterLayer, RasterStack and RasterBrick. They can also be extracted from objects descending from the Spatial class from the sp package. You can check this with the extent function. New Extent objects can be also be created with function extent and drawExtent by clicking twice on a plot.

See Also

expand, merge

Examples

Run this code
r <- raster(nrow=45, ncol=90)
r[] <- 1:ncell(r)
e <- extent(-160, 10, 30, 60)
rc <- crop(r, e)

Run the code above in your browser using DataLab