raster (version 1.1.7)

crop: Crop

Description

crop returns a geographic subset of the input RasterLayer 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 RasterLayer object
y
Extent object, or any object from which an Extent object can be extracted (see below)
...
additional arguments. See Details.

Value

  • A new RasterLayer object, and in some cases the side effect of a new file on disk.

Details

Objects that have a Extent object include RasterLayer, RasterStack and RasterBrick. They can also be extracted from objects descending from the Spatial class in the sp package. You can check this with the extent function. New Extent objects can be also be created with link[raster]{extent} and with drawExtent by clicking twice on a plot. If no filename is specified, and the resulting RasterLayer is too large to hold in memory, it is saved to a temporary file. The following additional arguments can be passed, to replace default values for this function rll{ filename Output filename (can be absent for RasterLayers that can be stored in memory) format Character. Output file type. See writeRaster overwrite Logical. If TRUE, "filename" will be overwritten if it exists progress Character. Valid values are "text", "tcltk", "windows" (on that platform only) and "" }

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 DataCamp Workspace