1

I received the following warning when trying to write a large raster (global extent) and am not sure how to proceed:

Error in .local(.Object, ...) : Unable to create dataset 

Note that I had to change the R temp file location to larger drive using rasterOptions():

rasterOptions(tmpdir="E:\\rTemp")

Also, I've read that removing any underscores from the file name when calling writeRaster() could resolve the issue, but it did not in my case.

The raster layer:

myRaster
class       : RasterLayer 
dimensions  : 67200, 172800, 11612160000  (nrow, ncol, ncell)
resolution  : 0.002083333, 0.002083333  (x, y)
extent      : -180, 179.9999, -56.00081, 83.99917  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 
data source : E:\rTemp\r_tmp_2017-09-25_010935_1648_64229.grd 
names       : layer 
values      : 1, 4  (min, max)

sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rasterVis_0.41      latticeExtra_0.6-28 RColorBrewer_1.1-2  lattice_0.20-35     dplyr_0.7.2         rgdal_1.2-8         raster_2.5-8       
[8] sp_1.2-5           

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.12      zoo_1.8-0         viridisLite_0.2.0 assertthat_0.2.0  grid_3.4.1        R6_2.2.2          magrittr_1.5      rlang_0.1.1      
 [9] hexbin_1.27.1     bindrcpp_0.2      tools_3.4.1       glue_1.1.1        parallel_3.4.1    compiler_3.4.1    pkgconfig_2.0.1   bindr_0.1        
[17] tibble_1.3.3
  • From your comment on the answer, it looks like your R environment/workspace may have been the issue rpubs.com/msundar/large_data_analysis – GISKid Sep 27 '17 at 17:18
  • @GISKid, are you sure that is the correct link? I am having a similar issue as SoilSciGuy but I'm not seeing any helpful info about environments or workspaces in your link. – Amadou Kone Jun 5 '18 at 13:50
  • @AmadouKone perhaps ask your own question? – GISKid Jun 6 '18 at 17:05
4

EDIT-1

Yes, I think raster formats is another topic to talk about and I also have to read more about them. But coming back to your problem, which you have already solved, I have an another pointing which can help other readers to the same problem: that kind of error (unable to create a dataset) from a raster file generrally occurs when you identify the raster file in a directory different from your working directory. From this, there are two ways to solve the problem. The former is to put all the raster files inside your working directory (the directory from your project), and the second (and the best option, in my opnion) is to use the option full.names = TRUE whithin the list.files() function, in the moment you are listing your rasters before the raster(filename) comand.

  • It's a geo-tif. I'm not sure what the problem was, but I restarted R and I was able to write the file. The output tif is 10.8 GB, so not sure about the file limit you mention. – SoilSciGuy Sep 25 '17 at 18:34
  • "The TIFF file formats use 32-bit offsets, which limits file size to 4 GiB (4,294,967,296 bytes). BigTIFF is a TIFF variant file format which uses 64-bit offsets and supports much larger files.[29] The BigTIFF file format specification was implemented in 2007 in development releases of LibTIFF version 4.0, which was finally released as stable in December 2011. Support for BigTIFF file formats by applications is limited." From link But the important is that the problem was solved. – José Lucas Safanelli Sep 25 '17 at 19:33
  • Right, BigTiff was implemented 10 years ago and stable for 6 years, so I'm still not sure why you mention it as being limited to 2GB. – SoilSciGuy Sep 26 '17 at 15:39
  • Your edit is interesting, and I used full.names=false. Although, I would remove the 2gb limit from your answer, the raster package supports bigtuff, and your answer may cause confusion. – SoilSciGuy Sep 27 '17 at 17:33
  • 1
    I got this error because I tried to write to a directory that I hadn't created yet. Thanks for the help! – philiporlando Sep 20 '18 at 5:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.