% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/spatial.R
\name{collect_sf}
\alias{collect_sf}
\title{Materialize a spatial query as an sf object}
\usage{
collect_sf(x, geom = "geometry", crs = NULL)
}
\arguments{
\item{x}{A \code{vectra_node} with a hex-WKB / WKT geometry column, or a
data.frame already collected from one.}

\item{geom}{Name of the geometry column. Default \code{"geometry"}.}

\item{crs}{Override the coordinate reference system. Defaults to the CRS the
node carries, or unknown.}
}
\value{
An \code{sf} object.
}
\description{
Collects a \code{vectra_node} (typically the result of \code{\link[=spatial_map]{spatial_map()}} or
\code{\link[=spatial_join]{spatial_join()}}) into memory and rebuilds an \code{sf} object from its hex-WKB
geometry column. The CRS defaults to the one carried on the node.
}
\details{
This is the spatial counterpart to \code{\link[=collect]{collect()}}: use it when the final result
fits in memory as \code{sf}. For a result still larger than RAM, keep it as a node
and write it out with \code{\link[=write_vtr]{write_vtr()}} (the geometry stays as a WKB string
column) or reduce it with \code{\link[=collect_chunked]{collect_chunked()}}.
}
\examples{
\dontshow{if (requireNamespace("sf", quietly = TRUE)) withAutoprint(\{ # examplesIf}
nc <- sf::st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE)
f <- tempfile(fileext = ".vtr")
write_vtr(data.frame(
  NAME = nc$NAME,
  geometry = sf::st_as_binary(sf::st_geometry(nc), hex = TRUE)
), f)
result <- tbl(f) |> spatial_map(~ sf::st_centroid(.x), crs = sf::st_crs(nc))
collect_sf(result)
unlink(f)
\dontshow{\}) # examplesIf}
}
\seealso{
\code{\link[=spatial_map]{spatial_map()}}, \code{\link[=spatial_join]{spatial_join()}}, \code{\link[=collect]{collect()}}.
}
