Learn R Programming

stppResid (version 1.1)

make.grid: Make a grid of spatial bins

Description

make.grid creates a space-time grid object of class “stgrid” for use with the functions gridresid and devresid.

Usage

make.grid(stw, grid = c(10, 10))

Arguments

stw
A space-time window object of class “stwin” to be divided into space-time bins.
grid
A vector representing the number of rows and columns in the grid.

Value

Outputs an object of class “stgrid”, which is a list of
grid.full
A data frame where each row represents a bin. There are four columns, xmin, xmax, ymin, and ymax, which represent the x and y limits of the bins.

Details

The space-time window, stw, is divided into a grid of space-time bins using the grid argument to determine the number of intervals in the x and y directions. The total number of bins will be the product of the elements of grid.

If grid is not specified, the default grid is 10 x 10, resulting in 100 total bins.

See Also

stwin, gridresid

Examples

Run this code
#===> create a space-time window  <===#
xcoord <- c(0, 10)
ycoord <- c(0, 20)
tcoord <- c(0, 100)
stw <- stwin(xcoord, ycoord, tcoord)

#===> create a 10 x 10 grid <===#
gf <- make.grid(stw)

#===> create a 10 x 20 grid <===#
gf <- make.grid(stw, c(10, 20))
nrow(gf$grid.full)
ncol(gf$grid.full)

Run the code above in your browser using DataLab