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)

Arguments

in_file

character file path of an RData file corresponding to a *Raster object or a GDAL vrt file

new_path

character path were the raster files to which in_file points were moved.

out_file

character filename were the updated RData or vrt file should be saved. If NULL, the new file is built by adding "_new" to the basename of the old one. If == "overwrite", the old file is overwritten. Default: NULL

Value

character path to the new "vrt" or "RData"

Examples

# 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)
# }