gridConstruct {lgc}  R Documentation 
gridConstruct
constructs a grid.
gridFilter
filters off unwanted grid points.
gridLocate
finds the closest grid point for a set
of locations.
gridFactor
constructs a gridFactor object.
gridConstruct(data, type = c("squareGrid", "triangularGrid", "scatterGrid"), filter = TRUE, wet = !wetEdges, wetEdges = FALSE, connected = TRUE, ordertol = 1, ...) gridFilter(grid, data, icesSquare = FALSE, nearestObs = Inf, wet = FALSE, connected = FALSE, ordertol = 0, wetEdges = FALSE, ...) gridLocate(grid, points) gridFactor(data, grid, ...)
data 
data.frame. 
type 
Neighborhood structure type. 
filter 
Call 
... 

center 
Optional list to control origo of grid. 
km 
Optional distance between neighboring grid points in km. 
icesSquare 
Remove grid points outside ICES squares in the data? 
nearestObs 
Remove grid points with closest data
point greater than 
wet 
Remove grid points on land. 
wetEdges 
Alternative: Keep edges passing through water. 
ordertol 
Require at least 
grid 

points 
These functions help to construct the object required to build Gaussian Markov Random fields with the formula interface. Most situations can be handled by
Creating a grid using grid <
gridConstruct(data)
.
Building a gridFactor object
using gridFactor(data,grid)
.
Construction of grids in practice generally involves 3 steps:
gridConstruct
 Construct
the grid sufficiently fine and sufficiently large to
contain all data points.
gridFilter
 Filter
off unwanted grid points. For instance grid points on
land or grid points too far away from the region of
interest.
gridLocate
 For each data point
locate the nearest grid point.
gridLocate
performs a brute force search of
closest gridpoint to each data point. The index of the
closest grid point is returned.
grid object
Filtered grid object
## Construct grid of North Sea and lookup points in the grid. ## Data df < data.frame(lon=c(0 ,1 ,5 ,6 ,2 ,2, 5, 1), lat=c(56,60,55,57,54,58,55,60)) ## Construct grid gr < gridConstruct(df,km=30,scale=1.3,filter=!FALSE) plot(gr);points(df);map("worldHires",add=TRUE) ## grid factor gf < gridFactor(df,gr) points(gr[gf,],col="red") ## Max distance to nearest grid point max(dist.km(df,gr[gf,],outer=FALSE)) ## 2. gr < gridConstruct(df,km=30,scale=1.3,nearestObs=100,connected=FALSE)