Read SpatRaster
from alabaster
on disk representation
readSpatRaster.Rd
Not the same as terra::rast
; here this function also reads the
metadata file.
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. IfNULL
, this is automatically read byreadObjectFile(path)
.- ...
Arguments passed to
rast
, character method.
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)