Tests if the bounding box of geometries in x intersect the bounding box of
geometries in y. Returns TRUE if the extents (bounding boxes) overlap.
This is faster than full geometry intersection but less precise.
Usage
ddbs_intersects_extent(
x,
y,
conn = NULL,
id_x = NULL,
id_y = NULL,
sparse = TRUE,
quiet = FALSE
)Arguments
- x
An
sfspatial object. Alternatively, it can be a string with the name of a table with geometry column within the DuckDB databaseconn. Data is returned from this object.- y
An
sfspatial object. Alternatively, it can be a string with the name of a table with geometry column within the DuckDB databaseconn.- conn
A connection object to a DuckDB database. If
NULL, the function runs on a temporary DuckDB database.- id_x
Character; optional name of the column in
xwhose values will be used to name the list elements. IfNULL, integer row numbers ofxare used.- id_y
Character; optional name of the column in
ywhose values will replace the integer indices returned in each element of the list.- sparse
A logical value. If
TRUE, it returns a sparse index list. IfFALSE, it returns a dense logical matrix.- quiet
A logical value. If
TRUE, suppresses any informational messages. Defaults toFALSE.
Value
A list where each element contains indices (or IDs) of geometries in y whose
bounding box intersects the bounding box of the corresponding geometry in x.
See ddbs_predicate() for details.
Details
This is a convenience wrapper around ddbs_predicate() with
predicate = "intersects_extent".
See also
ddbs_predicate() for other spatial predicates.
Examples
if (FALSE) { # \dontrun{
## load packages
library(dplyr)
library(duckspatial)
library(sf)
## read countries data, and rivers
countries_sf <- read_sf(system.file("spatial/countries.geojson", package = "duckspatial")) |>
filter(CNTR_ID %in% c("PT", "ES", "FR", "IT"))
rivers_sf <- st_read(system.file("spatial/rivers.geojson", package = "duckspatial")) |>
st_transform(st_crs(countries_sf))
# Fast bounding box intersection check
ddbs_intersects_extent(countries_sf, rivers_sf, id_x = "NAME_ENGL")
} # }
