Learn R Programming

wk (version 0.9.4)

grd_cell: Grid cell operators

Description

Grid cell operators

Usage

grd_cell(grid, point, ..., snap = grd_snap_next)

grd_cell_range( grid, bbox = wk_bbox(grid), ..., step = 1L, snap = grd_snap_next )

grd_cell_rct(grid, i, j = NULL, ...)

# S3 method for wk_grd_rct grd_cell_rct(grid, i, j = NULL, ..., out_of_bounds = "keep")

# S3 method for wk_grd_xy grd_cell_rct(grid, i, j = NULL, ..., out_of_bounds = "keep")

grd_cell_xy(grid, i, j = NULL, ...)

# S3 method for wk_grd_rct grd_cell_xy(grid, i, j = NULL, ..., out_of_bounds = "keep")

# S3 method for wk_grd_xy grd_cell_xy(grid, i, j = NULL, ..., out_of_bounds = "keep")

Value

  • grd_cell(): returns a list(i, j) of index values corresponding to the input points and adjusted according to snap. Index values will be outside dim(grid) for points outside wk_bbox(grid) including negative values.

  • grd_cell_range() returns a slice describing the range of indices in the i and j directions.

  • grd_cell_rct() returns a rct() of the cell extent at i, j.

  • grd_cell_xy() returns a xy() of the cell center at i, j.

Arguments

grid

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

point

A handleable of points.

...

Unused

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.

bbox

An rct() object.

step

The difference between adjascent indices in the output

i, 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.

out_of_bounds

One of 'keep', 'censor', 'discard', or 'squish'

Examples

Run this code
grid <- grd(nx = 3, ny = 2)
grd_cell(grid, xy(0.5, 0.5))
grd_cell_range(grid, grid$bbox)
grd_cell_rct(grid, 1, 1)
grd_cell_xy(grid, 1, 1)

Run the code above in your browser using DataLab