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.
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 wk_grd_rct
grd_crop(grid, bbox, ..., step = 1L, snap = NULL)
# S3 method for wk_grd_xy
grd_crop(grid, bbox, ..., step = 1L, snap = NULL)
# S3 method for wk_grd_rct
grd_extend(grid, bbox, ..., step = 1L, snap = NULL)
# S3 method for wk_grd_xy
grd_extend(grid, bbox, ..., step = 1L, snap = NULL)
grd_data_subset(grid_data, i = NULL, j = NULL)
A modified grid
whose cell centres have not changed location
as a result of the subset.
A grd_xy()
, grd_rct()
, or other object
implementing grd_*()
methods.
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
An rct()
object.
The difference between adjascent indices in the output
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.
The data
member of a grd()
. This is typically an
array but can also be an S3 object with an array-like subset method.
The native raster is special-cased as its
subset method requires non-standard handling.
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))
Run the code above in your browser using DataLab