grd_subset: Subset grid objects

Description Usage Arguments Value Examples

View source: R/subset.R

Description

The grd_subset() method handles the subsetting of a grd() in x-y space. Ordering of indices is not considered and logical indies are recycled silently along dimensions. The result of a grd_subset() is always a grd() of the same type whose relationship to x-y space has not changed.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
grd_subset(grid, i = NULL, j = NULL, ...)

grd_crop(grid, bbox, ..., step = 1L, snap = NULL)

grd_extend(grid, bbox, ..., step = 1L, snap = NULL)

## S3 method for class 'grd_rct'
grd_crop(grid, bbox, ..., step = 1L, snap = NULL)

## S3 method for class 'grd_xy'
grd_crop(grid, bbox, ..., step = 1L, snap = NULL)

## S3 method for class 'grd_rct'
grd_extend(grid, bbox, ..., step = 1L, snap = NULL)

## S3 method for class 'grd_xy'
grd_extend(grid, bbox, ..., step = 1L, snap = NULL)

Arguments

grid

A grd_xy(), grd_rct(), or other object implementing grd_*() methods.

i

1-based index values. i indices correspond to decreasing y values; j indices correspond to increasing x values. Values outside the range 1:nrow|ncol(data) will be censored to NA including 0 and negative values.

j

1-based index values. i indices correspond to decreasing y values; j indices correspond to increasing x values. Values outside the range 1:nrow|ncol(data) will be censored to NA including 0 and negative values.

...

Passed to subset methods

bbox

An wk::rct() object.

step

The difference between adjascent indices in the output

snap

A function that transforms real-valued indices to integer indices (e.g., floor(), ceiling(), or round()). For grd_cell_range(), a list() with exactly two elements to be called for the minimum and maximum index values, respectively.

Value

A modified grid whose cell centres have not changed location as a result of the subset.

Examples

1
2
3
4
grid <- grd_rct(volcano)
grd_subset(grid, 1:20, 1:30)
grd_crop(grid, rct(-10, -10, 10, 10))
grd_extend(grid, rct(-10, -10, 10, 10))

paleolimbot/grd documentation built on Dec. 22, 2021, 6:38 a.m.