polyCutout {RSurvey} | R Documentation

## Cutout Grid Points within Polygon

### Description

This function excludes data points outside a given polygon.

### Usage

    polyCutout(dat, ply)

### Arguments

`dat` | a list containing `x`, `y`, and `z` components, see Value section.
`ply` | a polygon of class `gpc.poly-class`.

### Details

Returns `NA` values for `z` when points (`x`, `y`) are located outside the polygon.

### Value

A list containing the following components:

`x` | grid point locations in the x-direction.
`y` | grid point locations in the y-direction.
`z` | a matrix of state variable values corresponding to the grid.

### Author(s)

Fisher, J. C.

### See Also

`point.in.polygon`, `filled.contour`

### Examples

    x11()

    ply <- as(cbind(c(2, 8, 9, 6, 3), c(3, 1, 4, 8, 6)), "gpc.poly")
    x <- seq(0, 10, 0.1)
    y <- seq(0, 10, 0.1)
    z <- matrix(runif(length(x) * length(y)),
         nrow = length(y), ncol = length(x))

    dat.old <- list(x = x, y = y, z = z)
    filled.contour(dat.old,
        plot.axes = {axis(1); axis(2); plot(ply, add = TRUE)})

    dat.new <- polyCutout(dat.old, ply)
    filled.contour(dat.new, color.palette = terrain.colors)

[Package RSurvey version 0.4.5 Index]