gridConstruct {lgc} R Documentation

## Construct a grid based on observation locations.

### Description

`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.

### Usage

```  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, ...)
```

### Arguments

 `data` data.frame. `type` Neighborhood structure type. `filter` Call `gridFilter` after grid construction? `...` `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 `nearestObs`. `wet` Remove grid points on land. `wetEdges` Alternative: Keep edges passing through water. `ordertol` Require at least `ordertol` neighbors to every grid point. `grid` `points`

### Details

These functions help to construct the object required to build Gaussian Markov Random fields with the formula interface. Most situations can be handled by

1. Creating a grid using ```grid <- gridConstruct(data)```.

2. Building a gridFactor object using `gridFactor(data,grid)`.

Construction of grids in practice generally involves 3 steps:

1. `gridConstruct` - Construct the grid sufficiently fine and sufficiently large to contain all data points.

2. `gridFilter` - Filter off unwanted grid points. For instance grid points on land or grid points too far away from the region of interest.

3. `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.

### Value

grid object

Filtered grid object

### Examples

```## 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)