问题描述
我正在使用R中的Raster包将数据集写入ERMapper格式(.ers)的文件中,但是生成的.aux.xml辅助文件存在问题(我实际上对此并不感兴趣) .
I'm writing a dataset to file in ERMapper format (.ers) using the Raster package in R, but I'm having issues with the resulting .aux.xml auxiliary file (which I'm actually not interested in).
简单的例子:
rst <- raster(ncols=15000,nrows=10000)
rst[] <- 1.234
writeRaster(rst, filename='_test.ers', overwrite=TRUE)
writeRaster()
行需要一些时间来执行,数据文件非常大,磁盘上约为1.2GB.
The writeRaster()
line takes some time to execute, the data file is quite large, about 1.2GB on disk.
检查执行writeRaster()
时发生的情况时,我发现.ers文件(头文件+关联的数据文件)通常在大约20秒内生成.然后,又需要writeRaster()
20到25秒才能生成.aux.xml文件,该文件仅包含诸如min,max,mean和st的统计信息.开发. (这可能解释了为什么要花这么长时间进行计算).
When checking what's happening while writeRaster()
is executed, I find that the .ers file (header file + associated data file) is typically generated in about 20 sec. Then, it takes writeRaster()
another 20 - 25 sec to generate the .aux.xml file, which only contains statistics such as min, max, mean, and st. dev. (which likely explains why it takes so long to compute).
由于我不在乎.aux.xml文件,因此我希望writeRaster()
完全不要理会它,并为我节省20-25秒的执行时间(我正在编写许多这样的数据集)到磁盘,因此我的代码中50%的加速是相当可观的.)
Since I don't care about the .aux.xml file, I would like writeRaster()
to not bother with it at all, and save me 20 - 25 sec of exec time (I'm writing lots of these datasets to disk so a 50% speedup in my code is quite substantial).
任何人都知道如何告诉writeRaster()
不创建.aux.xml文件吗?我怀疑这是与GDAL相关的问题,但经过大量研究仍无法找到答案...
Anyone has any idea how to tell writeRaster()
to not create a .aux.xml file? I suspect it's a GDAL-related issue, but haven't been able to find an answer yet after much research...
最有帮助的人!
推荐答案
可以使用(不太容易找到)rgdal::setCPLConfigOption
函数设置与GDAL文件格式驱动程序相关的选项.
Options related to the GDAL file format drivers can be set using the (not so easy to find) rgdal::setCPLConfigOption
function.
就您而言,
rgdal::setCPLConfigOption("GDAL_PAM_ENABLED", "FALSE")
应禁用xml
文件创建.
HTH
这篇关于R:如何在没有辅助文件的情况下将栅格写入磁盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!