function allowing to update the paths contained in "virtual rasters"
such as GDAL VRTs or R
rasterStacks "pointing" to files on disk in the case that
the corresponding files on disk are moved.
migrate_virtrast(in_file, new_path, out_file = NULL)
in_file |
|
---|---|
new_path |
|
out_file |
|
character
path to the new "vrt" or "RData"
# NOT RUN { # suppose you had a gdal vrt file "pointing" to tiff files originally located in # "/home/mypath/myfolder", and you successively moved them to "/home/mypath/mynewfolder" # If you want to update the vrt file so that it keeps working: #TODO (Remove the # after uploading a test dataset on sprawl.data) #old_vrt <- "/home/mypath/myfolder/myvrt.vrt #new_path <- "/home/mypath/mynewfolder" #new_vrt <- migrate_virtrast(old_vrt, new_path) #new_vrt #raster::stack(new_vrt) # # The same goes for RData files corresponding to "raster" objects #old_RData <- "/home/mypath/myfolder/myraster.RData #new_path <- "/home/mypath/mynewfolder" #new_RData <- migrate_virtrast(old_RData, new_path) #new_RData #raster::stack(new_RData) # }