Experimental low-level spatial join infrastructure based on the geos_basic_strtree().

geos_inner_join(
  x,
  y,
  predicate = "intersects",
  distance = NA,
  suffix = c(".x", ".y")
)

geos_inner_join_keys(x, y, predicate = "intersects", distance = NA)

Arguments

x, y

Geometry vectors with a wk::wk_handle() method.

predicate

One of:

  • intersects

  • contains

  • contains_properly

  • covered_by

  • covers

  • crosses

  • equals

  • equals_exact

  • intersects

  • within_distance

  • overlaps

  • touches

distance

Passed to geos_is_within_distance() when predicate is "within_distance"; passed to geos_equals_exact() when predicate is "equals_exact.

suffix

A character vector of length 2 with suffixes for the left and right sides for output columns with duplicated names.

Value

A data.frame with columns x and y corresponding to the 1-based indices on pairs of x and y for which predicate is TRUE.

Examples

x <- data.frame(
  col_x = "a",
  geometry = as_geos_geometry("POINT (10 10)")
)

y <- data.frame(
  col_y = "a",
  geometry = as_geos_geometry("POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))")
)

geos_inner_join(x, y, "intersects")
#>   col_x      geometry.x col_y                                geometry.y
#> 1     a <POINT (10 10)>     a <POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))>

geos_inner_join_keys(
  "POINT (5 5)",
  "POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))",
  "intersects"
)
#>   x y
#> 1 1 1