modify_raster_margins: Add/subtract rows and columns from Raster*

Description Usage Arguments Details Value Author(s) Examples

View source: R/modify_raster_margins.R

Description

Add/subtract rows and columns from Raster*

Usage

1
modify_raster_margins(x, extent_delta = c(0, 0, 0, 0), value = NA)

Arguments

x

A Raster* object.

extent_delta

Numeric vector. How many rows/columns to add/subtract to the left,right,top, and bottom of an image. Default is c(0,0,0,0) (no change).

value

Value to fill in when adding rows/columns.

Details

A quick way to add/subtract margins from a Raster* object. extent_delta is a four-element integer vector that describes how many rows/columns to add to the (left,right,top,bottom) of the image (in that order). Negative values remove rows, positive values add rows.

Value

A Raster* object.

Author(s)

Jonathan A. Greenberg

Examples

1
2
3
4
5
6
7
8
tahoe_highrez <- brick(system.file("external/tahoe_highrez.tif", package="spatial.tools"))
dim(tahoe_highrez)
# Remove one row and column from the top, bottom, left, and right:
tahoe_highrez_cropped <- modify_raster_margins(x=tahoe_highrez,extent_delta=c(-1,-1,-1,-1))
dim(tahoe_highrez_cropped)
# Add two rows to the top and left of the raster, and fill with the value 100.
tahoe_highrez_expand <- modify_raster_margins(x=tahoe_highrez,extent_delta=c(2,0,2,0),value=100)
dim(tahoe_highrez_expand)

azvoleff/spatial.tools documentation built on June 4, 2017, 12:08 a.m.