% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/st_join.R
\name{st_join.dbSpatial}
\alias{st_join.dbSpatial}
\title{Spatial join for dbSpatial objects}
\usage{
\method{st_join}{dbSpatial}(x, y, join = st_intersects, suffix = c(".x", ".y"), ...)
}
\arguments{
\item{x}{A \code{\link{dbSpatial}} object.}

\item{y}{A \code{\link{dbSpatial}} object.}

\item{join}{Spatial predicate function to use for the join. Default is
\code{st_intersects}. Supported predicates: \code{st_intersects},
\code{st_contains}, \code{st_within}, \code{st_covers}, \code{st_covered_by},
\code{st_crosses}, \code{st_disjoint}, \code{st_equals}, \code{st_touches},
\code{st_overlaps}.}

\item{suffix}{Character vector of length 2. Suffixes to add to duplicate
column names from x and y. Default is \code{c(".x", ".y")}.}

\item{...}{Additional arguments passed to the internal join function.}
}
\value{
A \code{\link{dbSpatial}} object containing the spatial join result.
}
\description{
Performs a spatial join between two dbSpatial objects using a specified
spatial predicate function.
}
\details{
This function follows the \code{sf} pattern where spatial predicates are passed
as the \code{join} argument.
}
\examples{
if (interactive() && requireNamespace("duckdb", quietly = TRUE)) {
  con <- DBI::dbConnect(duckdb::duckdb(), ":memory:")
  DBI::dbExecute(con, "SET threads = 1")

  df1 <- data.frame(id = 1:3, x = c(0, 10, 20), y = c(0, 10, 20))
  pts1 <- dbSpatial(conn = con, name = "pts1", value = df1,
                    x_colName = "x", y_colName = "y", overwrite = TRUE)

  df2 <- data.frame(id = 4:6, x = c(0, 15, 25), y = c(0, 15, 25))
  pts2 <- dbSpatial(conn = con, name = "pts2", value = df2,
                    x_colName = "x", y_colName = "y", overwrite = TRUE)

  # Spatial join using intersection
  result <- sf::st_join(pts1, pts2, join = sf::st_intersects)

  # Spatial join using within predicate
  result <- sf::st_join(pts1, pts2, join = sf::st_within)

  DBI::dbDisconnect(con, shutdown = TRUE)
}

}
