EVOLUTION-MANAGER
Edit File: geos_binary_pred.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Geometric binary predicates on pairs of simple feature...</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for geos_binary_pred {sf}"><tr><td>geos_binary_pred {sf}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Geometric binary predicates on pairs of simple feature geometry sets</h2> <h3>Description</h3> <p>Geometric binary predicates on pairs of simple feature geometry sets </p> <h3>Usage</h3> <pre> st_intersects(x, y, sparse = TRUE, ...) st_disjoint(x, y = x, sparse = TRUE, prepared = TRUE) st_touches(x, y, sparse = TRUE, prepared = TRUE, ...) st_crosses(x, y, sparse = TRUE, prepared = TRUE, ...) st_within(x, y, sparse = TRUE, prepared = TRUE, ...) st_contains(x, y, sparse = TRUE, prepared = TRUE, ..., s2_model = "open") st_contains_properly(x, y, sparse = TRUE, prepared = TRUE, ...) st_overlaps(x, y, sparse = TRUE, prepared = TRUE, ...) st_equals(x, y, sparse = TRUE, prepared = FALSE, ...) st_covers(x, y, sparse = TRUE, prepared = TRUE, ..., s2_model = "closed") st_covered_by( x, y = x, sparse = TRUE, prepared = TRUE, ..., s2_model = "closed" ) st_equals_exact(x, y, par, sparse = TRUE, prepared = FALSE, ...) st_is_within_distance(x, y, dist, sparse = TRUE, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>object of class <code>sf</code>, <code>sfc</code> or <code>sfg</code></p> </td></tr> <tr valign="top"><td><code>y</code></td> <td> <p>object of class <code>sf</code>, <code>sfc</code> or <code>sfg</code>; if missing, <code>x</code> is used</p> </td></tr> <tr valign="top"><td><code>sparse</code></td> <td> <p>logical; should a sparse index list be returned (TRUE) or a dense logical matrix? See below.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>passed on to <a href="../../s2/html/s2_options.html">s2_options</a></p> </td></tr> <tr valign="top"><td><code>prepared</code></td> <td> <p>logical; prepare geometry for x, before looping over y? See Details.</p> </td></tr> <tr valign="top"><td><code>s2_model</code></td> <td> <p>character; polygon/polylin model; one of "OPEN", "SEMI_OPEN", and "CLOSED"; see Details.</p> </td></tr> <tr valign="top"><td><code>par</code></td> <td> <p>numeric; parameter used for "equals_exact" (margin);</p> </td></tr> <tr valign="top"><td><code>dist</code></td> <td> <p>distance threshold; geometry indexes with distances smaller or equal to this value are returned; numeric value or units value having distance units.</p> </td></tr> </table> <h3>Details</h3> <p>If <code>prepared</code> is <code>TRUE</code>, and <code>x</code> contains POINT geometries and <code>y</code> contains polygons, then the polygon geometries are prepared, rather than the points. </p> <p>For most predicates, a spatial index is built on argument <code>x</code>; see <a href="http://r-spatial.org/r/2017/06/22/spatial-index.html">http://r-spatial.org/r/2017/06/22/spatial-index.html</a>. Specifically, <code>st_intersects</code>, <code>st_disjoint</code>, <code>st_touches</code> <code>st_crosses</code>, <code>st_within</code>, <code>st_contains</code>, <code>st_contains_properly</code>, <code>st_overlaps</code>, <code>st_equals</code>, <code>st_covers</code> and <code>st_covered_by</code> all build spatial indexes for more efficient geometry calculations. <code>st_relate</code>, <code>st_equals_exact</code>, and <code>st_is_within_distance</code> do not. </p> <p>If <code>y</code> is missing, 'st_predicate(x, x)' is effectively called, and a square matrix is returned with diagonal elements 'st_predicate(x[i], x[i])'. </p> <p>Sparse geometry binary predicate (<code><a href="sgbp.html">sgbp</a></code>) lists have the following attributes: <code>region.id</code> with the <code>row.names</code> of <code>x</code> (if any, else <code>1:n</code>), <code>ncol</code> with the number of features in <code>y</code>, and <code>predicate</code> with the name of the predicate used. </p> <p>for <code>s2_model</code>, see https://github.com/r-spatial/s2/issues/32 </p> <p>‘st_contains_properly(A,B)' is true if A intersects B’s interior, but not its edges or exterior; A contains A, but A does not properly contain A. </p> <p>See also <a href="st_relate.html">st_relate</a> and <a href="https://en.wikipedia.org/wiki/DE-9IM">https://en.wikipedia.org/wiki/DE-9IM</a> for a more detailed description of the underlying algorithms. </p> <p><code>st_equals_exact</code> returns true for two geometries of the same type and their vertices corresponding by index are equal up to a specified tolerance. </p> <h3>Value</h3> <p>If <code>sparse=FALSE</code>, <code>st_predicate</code> (with <code>predicate</code> e.g. "intersects") returns a dense logical matrix with element <code>i,j</code> <code>TRUE</code> when <code>predicate(x[i], y[j])</code> (e.g., when geometry of feature i and j intersect); if <code>sparse=TRUE</code>, an object of class <code><a href="sgbp.html">sgbp</a></code> with a sparse list representation of the same matrix, with list element <code>i</code> an integer vector with all indices j for which <code>predicate(x[i],y[j])</code> is <code>TRUE</code> (and hence a zero-length integer vector if none of them is <code>TRUE</code>). From the dense matrix, one can find out if one or more elements intersect by <code>apply(mat, 1, any)</code>, and from the sparse list by <code>lengths(lst) > 0</code>, see examples below. </p> <h3>Note</h3> <p>For intersection on pairs of simple feature geometries, use the function <code><a href="geos_binary_ops.html">st_intersection</a></code> instead of <code>st_intersects</code>. </p> <h3>Examples</h3> <pre> pts = st_sfc(st_point(c(.5,.5)), st_point(c(1.5, 1.5)), st_point(c(2.5, 2.5))) pol = st_polygon(list(rbind(c(0,0), c(2,0), c(2,2), c(0,2), c(0,0)))) (lst = st_intersects(pts, pol)) (mat = st_intersects(pts, pol, sparse = FALSE)) # which points fall inside a polygon? apply(mat, 1, any) lengths(lst) > 0 # which points fall inside the first polygon? st_intersects(pol, pts)[[1]] </pre> <hr /><div style="text-align: center;">[Package <em>sf</em> version 0.9-5 <a href="00Index.html">Index</a>]</div> </body></html>