Learn R Programming

geoR (version 1.6-21)

polygrid: Coordinates of Points Inside a Polygon

Description

This function builds a rectangular grid and extracts points which are inside of an internal polygonal region.

Usage

polygrid(xgrid, ygrid, borders, vec.inout = FALSE, ...)

Arguments

xgrid
grid values in the x-direction.
ygrid
grid values in the y-direction.
borders
a matrix with polygon coordinates defining the borders of the region.
vec.inout
logical. If TRUE a logical vector is included in the output indicating whether each point of the grid is inside the polygon. Defaults to FALSE.
...
currently not used (kept for back compatibility).

Value

  • A list with components:
  • xypolyan $n \times 2$ matrix with the coordinates of the points inside the polygon.
  • vec.inoutlogical, a vector indicating whether each point of the rectangular grid is inside the polygon. Only returned if vec.inout = TRUE.

code

ksline

pkg

  • sp
  • geoR

Details

The function works as follows: First it creates a grid using the R

References

Further information on the package geoR can be found at: http://www.leg.ufpr.br/geoR.

See Also

expand.grid, overlay, SpatialPoints.

Examples

Run this code
poly <- matrix(c(.2, .8, .7, .1, .2, .1, .2, .7, .7, .1), ncol=2)
 plot(0:1, 0:1, type="n")
 lines(poly)
 poly.in <- polygrid(seq(0,1,l=11), seq(0,1,l=11), poly, vec=TRUE)
 points(poly.in$xy)

Run the code above in your browser using DataLab