R: how to write a bitmap to disk without an auxiliary file?

I am writing a dataset for an ERMapper (.ers) file using the Raster package in R, but I am having problems with the resulting auxiliary .aux.xml file (which I am not actually interested in).

Simple example:

rst <- raster(ncols=15000,nrows=10000)
rst[] <- 1.234
writeRaster(rst, filename='_test.ers', overwrite=TRUE)

      

The line writeRaster()

takes some time to execute, the data file is quite large, about 1.2 GB on disk.

While checking what is happening at runtime writeRaster()

, I found that the .ers file (header file + associated data file) usually generates in about 20 seconds. Then it takes writeRaster()

another 20-25 seconds to create the .aux.xml file , which contains only statistics such as min, max, mean and st. deviation (which probably explains why it takes so long to compute).

Since I don't need the .aux.xml file, I would like writeRaster()

not to worry about it at all and save me 20 - 25 seconds of runtime (I write a lot of these datasets to disk, so 50% speedup in my code is pretty significant) ...

Does anyone know how to tell writeRaster()

not to create a .aux.xml file? I suspect this is a GDAL related issue, but haven't been able to find an answer yet after much research ...

Any help is appreciated!

+3


source to share


1 answer


The parameters associated with the GDAL file format drivers can be set using a function (not easy to find) rgdal::setCPLConfigOption

.

In your case

rgdal::setCPLConfigOption("GDAL_PAM_ENABLED", "FALSE")

      



should disable file creation xml

.

NTN

+3


source







All Articles