Creates an equally spaced grid covering the range of the supplied
coordinates. Works with any coordinate system (UTM metres, UTM
kilometres, lon/lat degrees, etc.) — resolution and the
coordinates must simply be in the same units. The grid origin is
snapped down to the nearest resolution multiple below each
coordinate minimum. Optionally repeats the spatial grid for every
element of time, adding a year column. Optionally
removes grid nodes that are farther than max_dist from any
observation (requires the RANN package).
Arguments
- x
Numeric vector of X coordinates (any units).
- y
Numeric vector of Y coordinates (same units as
x).- resolution
Step size between grid nodes, in the same units as
xandy.- max_dist
Optional distance threshold in the same units as
xandy. Grid nodes whose nearest observation is farther thanmax_distare dropped. Uses a k-d tree via RANN for efficiency.- time
Optional vector of time values (e.g.
1990:2000). When supplied the spatial grid is crossed withtimeand ayearcolumn is added.
