query provides a interface for table-based
subsetting of SpatialData objects. It filters a specified
table using dplyr::filter logic and propagates the result
to all associated spatial elements (i.e., only instances
present in the filtered table are kept).
For spatial cropping, see crop.
Arguments
- x
SpatialDataobject.- ...
logic passed to
dplyr::filter.- i
index or name of table to query.
Examples
zs <- file.path("extdata", "blobs.zarr")
zs <- system.file(zs, package="SpatialData")
sd <- readSpatialData(zs)
# filter by 'region' and propagate to shapes/points
t <- table(sd)
query(sd, i=1, region == region(t))
#> class: SpatialData
#> - images(0):
#> - labels(1):
#> - blobs_labels (64,64)
#> - points(0):
#> - shapes(0):
#> - tables(1):
#> - table (3,10) [blobs_labels]
#> coordinate systems(5):
#> - global(1): blobs_labels
#> - scale(1): blobs_labels
#> - translation(1): blobs_labels
#> - affine(1): blobs_labels
#> - sequence(1): blobs_labels