Collects a vectra_node (typically the result of spatial_map() or
spatial_join()) into memory and rebuilds an 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 collect(): use it when the final result
fits in memory as sf. For a result still larger than RAM, keep it as a node
and write it out with write_vtr() (the geometry stays as a WKB string
column) or reduce it with collect_chunked().
Examples
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)