Learn R Programming

ocean (version 0.2-4)

is.in.grid: Checks if the points (xy$x, xy$y) are in the fvcom.grid grid.

Description

Checks if the points (xy$x, xy$y) are in the fvcom.grid grid.

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 logical values of length nrow(xy). The ith element is TRUE if (xy$x[i], xy$y[i]) is in grid and FALSE otherwise.

Examples

Run this code
{
# Create a regular grid of test points
nodes = get.nodes(ocean.demo.grid)
lattice.grid = expand.grid(x=seq(min(nodes$x), max(nodes$x), len=25),
                           y=seq(min(nodes$y), max(nodes$y), len=25))
# Check which points are in the grid
in.grid = is.in.grid(ocean.demo.grid, lattice.grid, units="m")
# Plot the points that are in the grid
with(lattice.grid[in.grid,], plot(x, y))
}

Run the code above in your browser using DataLab