polygrid: Coordinates of Points Inside a Polygon

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

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

Usage

1
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).

Details

The function works as follows: First it creates a grid using the R function expand.grid and then it uses the geoR' internal function .geoR_inout() which wraps usage of SpatialPoints and over from the package sp to extract the points of the grid which are inside the polygon.

Value

A list with components:

xypoly

an n x 2 matrix with the coordinates of the points inside the polygon.

vec.inout

logical, a vector indicating whether each point of the rectangular grid is inside the polygon. Only returned if vec.inout = TRUE.

Author(s)

Paulo Justiniano Ribeiro Jr. paulojus@leg.ufpr.br,
Peter J. Diggle p.diggle@lancaster.ac.uk.

References

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

See Also

expand.grid, over, SpatialPoints.

Examples

1
2
3
4
5
 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)

Example output

Loading required package: sgeostat
Registered S3 method overwritten by 'geoR':
  method         from    
  plot.variogram sgeostat
Warning messages:
1: no DISPLAY variable so Tk is not available 
2: In rgl.init(initValue, onlyNULL) : RGL: unable to open X11 display
3: 'rgl.init' failed, running with 'rgl.useNULL = TRUE'. 

StatDA documentation built on March 13, 2020, 2:42 a.m.

Related to polygrid in StatDA...