Learn R Programming

geoBayes (version 0.3.0)

mkpredgrid2d: Make prediction grid

Description

This function creates a grid for prediction.

Usage

mkpredgrid2d(pnts.x, pnts.y, par.x, par.y, isby = FALSE, chull = FALSE,
  exf = 1)

Arguments

pnts.x
x coordinate of the domain. Could also be a two-column matrix containing the x and y coordinates
pnts.y
y coordinate of the domain. Should be omitted or set to NULL if the argument pnts.x is a two-column matrix.
par.x
A scalar parameter for the x component of the new grid. This parameter corresponds to either the by or the length.out arguments of the function seq. Could also be a vector of two e
par.y
As in par.x for the y component of the new grid. Should be omitted or set to NULL if the argument par.x is a two-dimensional vector.
isby
If TRUE, the arguments par.x and par.y correspond to the by argument of the function seq, otherwise they correspond to length.out.
chull
Whether to calculate the convex hull of the points. Set this to TRUE if pnts.x and pnts.y denote the sampled locations. If they correspond to the borders of the domain, it is recommended to set this to FALSE
exf
An expansion factor of the convex hull of cbind(pnts.x, pnts.y). Must be positive. If larger or smaller than 1, the convex hull is respectively expanded or contracted.

Value

  • A list with components
    • gridA two-column matrix with the prediction grid
    • xycoordA list with components "x" and "y" containing the sequence of points used to create the grid
    • xygridA matrix with the full square grid derived fromxycoord
    • bordersThe (expanded) borders of the domain

Details

If chull this function first calculates the convex hull of the points. If exf is not 1 the borders are expanded. Then the function calls point.in.polygon to select points that fall inside the borders.

See Also

pred_grid

Examples

Run this code
data(rhizoctonia)
predgrid <- mkpredgrid2d(rhizoctonia[c("Xcoord", "Ycoord")],
                         par.x = 100, chull = TRUE, exf = 1.2)
plot(predgrid$borders, type = "l")         # Domain for prediction
points(predgrid$grid, pch = 20, cex = .3)  # Prediction locations
points(rhizoctonia[c("Xcoord", "Ycoord")]) # Observed locations

Run the code above in your browser using DataLab