This is a draft PR that might be able to address #58
This is a completely different way of managing target files--where the target file in _targets/objects/ is an RDS file (like ordinary targets) containing a PackedSpatRaster which is backed by a cached geospatial data file (and any sidecars) held in a user-specified folder
Source data file is written using terra::wrapCache() to a user-specified cache directory
Target (custom format, saves RDS in target store) is created for PackedSpatRaster which is linked to the cache files
Target (format="file") is created for cache files
Add cache-managing functions geotargets_destroy_cache(), geotargets_init_cache() and env option for cache path GEOTARGETS_CACHE_DIR (and associated methods)
For now this only works for SpatRaster, but I think a similar solution could be developed for SpatVectorProxy (although this would require either changes to wrapCache() in terra, or a custom wrapCache()-like method developed for this case)
Current "issue" is that you can modify the cache (intentionally or unintentionally) and the main target will not be invalidated. I tried tracking the cache directory before running the caching target, but then this leads to the caching having to run twice before it is skipped.
This is a draft PR that might be able to address #58
This is a completely different way of managing target files--where the target file in _targets/objects/ is an RDS file (like ordinary targets) containing a PackedSpatRaster which is backed by a cached geospatial data file (and any sidecars) held in a user-specified folder
terra::wrapCache()
to a user-specified cache directorygeotargets_destroy_cache()
,geotargets_init_cache()
and env option for cache path GEOTARGETS_CACHE_DIR (and associated methods)For now this only works for SpatRaster, but I think a similar solution could be developed for SpatVectorProxy (although this would require either changes to
wrapCache()
in terra, or a customwrapCache()
-like method developed for this case)Current "issue" is that you can modify the cache (intentionally or unintentionally) and the main target will not be invalidated. I tried tracking the cache directory before running the caching target, but then this leads to the caching having to run twice before it is skipped.
Example of storing units and categories: