Filters x down to the rows whose geometry relates to any row of y.
Unlike ga_join(), it does not attach the columns of y.
Arguments
- x, y
data frames, each with one GeoArrow geometry column
- predicate
a sparse predicate, by default
ga_sparse_intersects()
Details
ga_filter() keeps a row of x when the predicate finds at least one match
for it in y, so ga_filter(sites, counties, ga_sparse_within) keeps the
sites that fall in any county. ga_filter() matches ST_Filter(), and
returns the same rows as ga_join(x, y, predicate, left = FALSE) would,
without the columns of y and without repeating rows of x.
Examples
nc <- as.data.frame(read_shapefile(
system.file("shape/nc.shp", package = "sf")
))
sites <- data.frame(
site = c("a", "b", "c"),
geometry = geoarrow::as_geoarrow_vctr(
ga_point(c(-78.6, -80.8, 0), c(35.8, 35.2, 0))
)
)
# the third site is in the Atlantic, so ga_filter() drops it
ga_filter(sites, nc, ga_sparse_within)
#> Table
#> 2 rows x 2 columns
#> $site <string>
#> $geometry: geoarrow.point <crs <unspecified>>
#>
#> See $metadata for additional Schema metadata