To modify a grid is to align an extent to the grid origin. Modification includes to reduce or extend the area covered, in either dimension. This implies a new extent, snapped to the grain of the origin grid and a new size (dimension in x,y).

vcrop(x, dimension, extent = NULL, ..., snap = "out")

Arguments

x

extent of candidate grid (vector of xmin,xmax,ymin,ymax)

dimension

integer ncol, nrow

extent

numeric extent xmin,xmax,ymin,ymax

...

ignored

snap

one of "out" (default), "near", or "in"

Details

This works for any grid, the input extent can be within the original, an extension of the original, or completely non-intersecting the original grid.

Examples

## any arbitrary extent
x <- c(sort(runif(2, -180, 180)), sort(runif(2, -90, 90)))
print(x)
#> [1]  83.83752  98.10774 -58.51069  67.42812
vcrop(x,  c(360, 180), c(-180, 180, -90, 90))
#> $extent
#> [1]  83  99 -59  68
#> 
#> $dimension
#> [1]  16 127
#>