generate.grid.centers: Compute center coordinates of cells in a regular grid

Description Usage Arguments Value Author(s) Examples

View source: R/generate-grid-centers.R

Description

Given a rectangular extent and a resolution in both the x- and y-directions, this function computes the coordinates of the centers of the grid cells.

Usage

1
2
generate.grid.centers(x.lower, x.upper, y.lower, y.upper, resolution.x,
  resolution.y, params, separate = FALSE)

Arguments

x.lower, x.upper, y.lower, y.upper

Specifies the boundaries of the rectangular region that the GRF is defined on.

resolution.x, resolution.y

The number of grid cells used for the regular grid, in the x- and y-direction, respectively.

params

The parameters above can instead be specified in the list params.

separate

If true, the function returns the x- and y-coordinates of the centers in separate vectors.

Value

A (resolution.x*resolution.y) x 2 matrix specifying the centers of the grid cells. If separate = FALSE, a list of two vectors of length resolution.x and resolution.y.

Author(s)

Mathias Isaksen mathiasleanderi@gmail.com

Examples

1
2
3
4
5
6
library(GRFics)
# Create a 15 x 15 regular grid on [-1, 1]^2
reg.grid = generate.grid.centers(-1, 1, -1, 1, 15, 15)
plot(reg.grid, asp = 1, pch = 16)
abline(h = seq(-1, 1, length.out = 16),
       v = seq(-1, 1, length.out = 16))

mathiasisaksen/GRFics documentation built on May 20, 2021, 5:55 a.m.