Closed courtiol closed 8 months ago
@rhijmans, if you have thoughts, please share them with us :-)
I think you can define a saveRDS
method for these objects. These can then call terra::wrap
for SpatRaster/SpatVector objects before calling base::saveRDS
. That is what terra does for saveRDS<SpatVector>
and saveRDS<SpatRaster>
. And do the inverse for readRDS
.
Problem
It is no longer possible to directly save objects created by IsoriX onto the hard drive with terra.
Context
When relying on raster it was possible to save objects created by IsoriX onto the hard drive as
*.rda
or*.rds
.Objects created by IsoriX are composite in the sense that they may contain rasters, spatial vectors, and non-spatial info all bundled together as a list.
Those list cannot be saved with terra since this package has functions designed to save rasters or vectors specifically and no function to store any kinds of composite.
This matters for users because spatial objects created by IsoriX can be very slow to create. This also matters to me for editing the bookdown.
Solution
Turning files into binaries ("serialisation") does not seem to be a recommended practice for spatial objects, and even with raster it led to issues if the values were not stored in memory.
So the solution seems to implement methods to save specific classes of IsoriX-created objects. These methods would create a folder with a particular structure within which the different parts of the objects would be saved separately.
We would also have methods to read these folders so as to recreate the IsoriX objects.
Objects created in IsoriX containing spatial data
ISOFIT
: a list storing various info and no spatial data.MULTIISOFIT
: a list storing various info and no spatial data.CALIBFIT
: a list storing various info as well as 0 or 1 SpatVector and no SpatRaster.ISOSCAPE
: a list storing 1 SpatRaster and 1 SpatVector.ISOFIND
: a list of 3 lists, one containing 4 SpatRaster, one containing 1 SpatRaster, one containing (up to?) 3 SpatVector.Open questions
ISOFIND
to make it simpler (e.g. single brick)? (I need to check if various sets of points can be combined within a single SpatVector)