Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

inside.gpc.poly

Test Whether Points are Inside a "gpc.poly" Polygon


Description

Same as, e.g., inside.owin from package spatstat.geom and point.in.polygon from package sp, i.e., test whether points lie inside or outside a given polygon. Actually, the method for "gpc.poly" documented here internally uses the point.in.polygon function.

Usage

inside.gpc.poly(x, y = NULL, polyregion, mode.checked = FALSE)

Arguments

x,y

numeric vectors of coordinates of the points to be tested. The coordinates can be supplied in any form accepted by xy.coords.

polyregion

an object of class "gpc.poly". It is checked if the points specified through x and y fall into this polygonal region.

mode.checked

passed to point.in.polygon.

Details

The nodes and edges of (non-hole) polygons are treated as being inside. Points that fall strictly inside holes are treated as being outside of the polygon.

Value

Logical vector whose ith entry is TRUE if the corresponding point (x[i],y[i]) is inside polyregion.

Author(s)

Sebastian Meyer

Examples

if (requireNamespace("rgeos")) {
    poly <- discpoly(c(0.5,0.5), 0.5, npoly=4, class="gpc.poly")
    pts <- cbind(x=runif(50), y=runif(50))
    plot(poly)
    points(pts, col=1+inside.gpc.poly(pts, polyregion=poly))
}

surveillance

Temporal and Spatio-Temporal Modeling and Monitoring of Epidemic Phenomena

v1.19.1
GPL-2
Authors
Michael H<f6>hle [aut, ths] (<https://orcid.org/0000-0002-0423-6702>), Sebastian Meyer [aut, cre] (<https://orcid.org/0000-0002-1791-9449>), Michaela Paul [aut], Leonhard Held [ctb, ths], Howard Burkom [ctb], Thais Correa [ctb], Mathias Hofmann [ctb], Christian Lang [ctb], Juliane Manitz [ctb], Andrea Riebler [ctb], Daniel Saban<e9>s Bov<e9> [ctb], Ma<eb>lle Salmon [ctb], Dirk Schumacher [ctb], Stefan Steiner [ctb], Mikko Virtanen [ctb], Wei Wei [ctb], Valentin Wimmer [ctb], R Core Team [ctb] (A few code segments are modified versions of code from base R)
Initial release
2021-03-30

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.