Make prediction grid

Share:

Description

This function creates a grid for prediction.

Usage

1
2
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 elements containing the parameter for x and y.

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.

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.

Value

A list with components

  • grid A two-column matrix with the prediction grid

  • xycoord A list with components "x" and "y" containing the sequence of points used to create the grid

  • xygrid A matrix with the full square grid derived from xycoord

  • borders The (expanded) borders of the domain

See Also

pred_grid

Examples

1
2
3
4
5
6
7
8
9
## Not run: 
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

## End(Not run)