Returns the axis aligned bounding box of each geometry, as the box array that the spatial index queries take.
Details
A box array is passed straight through rather than recomputed, so this is cheap to call on something that already holds boxes and safe to call defensively before a query.
This is the envelope in the OGC sense. It differs from
ga_bounding_rect() only in that pass through; the boxes themselves are
the same.
See also
Other index:
KDTree,
RTree,
ga_knn_join(),
ga_set_thread_pool(),
ga_sparse_dwithin(),
ga_sparse_knn()
Examples
nc <- as.data.frame(read_shapefile(
system.file("shape/nc.shp", package = "sf")
))
boxes <- ga_envelope(nc$geometry)
head(geoarrow::as_geoarrow_vctr(boxes), 3)
#> <geoarrow_vctr geoarrow.box{struct}[3]>
#> [1] <POLYGON ((-81.7410736 36.2343559, -81.2398911 36.2343559, -81.2398911 >
#> [2] <POLYGON ((-81.3475418 36.3653641, -80.9034424 36.3653641, -80.9034424 >
#> [3] <POLYGON ((-80.9657745 36.2338829, -80.4353104 36.2338829, -80.4353104 >
# already boxes, so this is a no op
identical(
as.character(geoarrow::as_geoarrow_vctr(ga_envelope(boxes))),
as.character(geoarrow::as_geoarrow_vctr(boxes))
)
#> [1] TRUE