Description Arguments Value Examples
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.
grid |
A |
xy |
A |
units |
Either 'll' for latitude and longitude or 'm' for meters. |
A vector of integer values of length nrow(xy)
. The
values are indexes into the elements of grid.
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])
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.