Skip to contents

Not the same as terra::rast; here this function also reads the metadata file.

Usage

readSpatRaster(path, metadata = NULL, ...)

Arguments

path

String containing a path to a directory, itself created with a saveObject method.

metadata

Named list containing metadata for the object - most importantly, the type field that controls dispatch to the correct loading function. If NULL, this is automatically read by readObjectFile(path).

...

Arguments passed to rast, character method.

Value

A SpatRasterImage object for SFE.

See also

Other readObject-SFE-image: readBioFormatsImage(), readExtImage()

Examples

library(SFEData)
fp <- tempfile()
fn <- file.path(fp, "vizgen")
d <- VizgenOutput(dataset = "cellpose", file_path = fn)
#> see ?SFEData and browseVignettes('SFEData') for documentation
#> downloading 1 resources
#> retrieving 1 resource
#> loading from cache
#> The downloaded files are in /tmp/RtmpfBErth/file2aa8918181f/vizgen/vizgen_cellbound_Cellpose 
suppressWarnings(sfe <- readVizgen(d))
#> >>> 1 `.parquet` files exist:
#> /tmp/RtmpfBErth/file2aa8918181f/vizgen/vizgen_cellbound_Cellpose/Cellpose/cellpose_micron_space.parquet
#> >>> using -> /tmp/RtmpfBErth/file2aa8918181f/vizgen/vizgen_cellbound_Cellpose/Cellpose/cellpose_micron_space.parquet
#> >>> Cell segmentations are found in `.parquet` file
#> Sanity checks on cell segmentation polygons:
#> >>> ..found 1 cells with (nested) polygon lists
#> >>> ..applying filtering
#> >>> Casting MULTIPOLYGON geometry to POLYGON
#> >>> Checking polygon validity
img <- getImg(sfe)
class(img)
#> [1] "SpatRasterImage"
#> attr(,"package")
#> [1] "SpatialFeatureExperiment"
fsave <- file.path(fp, "img")
saveObject(img, fsave)
img2 <- readObject(fsave)