vsi_copy_file()
is a wrapper for VSICopyFile()
in the GDAL Common
Portability Library. The GDAL VSI functions allow virtualization of disk
I/O so that non file data sources can be made to appear as files.
See https://gdal.org/user/virtual_file_systems.html.
Requires GDAL >= 3.7.
Details
The following copies are made fully on the target server, without local download from source and upload to target:
/vsis3/ -> /vsis3/
/vsigs/ -> /vsigs/
/vsiaz/ -> /vsiaz/
/vsiadls/ -> /vsiadls/
any of the above or /vsicurl/ -> /vsiaz/ (starting with GDAL 3.8)
Note
If target_file
has the form /vsizip/foo.zip/bar, the default options
described for the function addFilesInZip()
will be in effect.
Examples
elev_file <- system.file("extdata/storml_elev.tif", package="gdalraster")
tmp_file <- "/vsimem/elev_temp.tif"
# Requires GDAL >= 3.7
if (as.integer(gdal_version()[2]) >= 3070000) {
result <- vsi_copy_file(elev_file, tmp_file)
print(result)
print(vsi_stat(tmp_file, "size"))
vsi_unlink(tmp_file)
}