find.elem-methods: Checks if the points (xy$x, xy$y) are in the 'fvcom.grid'...

Description Arguments Value Examples

Description

Given a grid and a point or set of points, find.elem returns the element number of each point in the grid. NA is returned for any point that does not lie within the grid. x and y must be the same length.

Arguments

grid

A fvcom.grid instance.

xy

A data.frame with components x and y with the x and y locations of the points.

units

Either 'll' for latitude and longitude or 'm' for meters.

Value

A vector of integer values of length nrow(xy). The values are indexes into the elements of grid.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
{
# Create a regular matrix grid
nodes = get.nodes(ocean.demo.grid)
lattice.grid = expand.grid(x=seq(min(nodes$x), max(nodes$x), len=50),
                           y=seq(min(nodes$y), max(nodes$y), len=50))
elems = find.elem(ocean.demo.grid, lattice.grid, units="m")
# Plot the result
plot(lattice.grid$x, lattice.grid$y, pch=15,
     col=jet.colors(max(elems, na.rm=TRUE) + 2)[elems+2])
}

ocean documentation built on Jan. 15, 2017, 4:16 p.m.