I'm trying to replicate the following example from package getCRUCLdata:

# Create a raster stack of temperature from tmp
# files in the tempdir() directory.
   url = "https://crudata.uea.ac.uk/cru/data/hrg/tmc/grid_10min_tmp.dat.gz",
   destfile = file.path(tempdir(), "grid_10min_tmp.dat.gz")
CRU_tmp <- create_CRU_stack(tmp = TRUE, dsn = tempdir())
CRU_tmpcode here

However, all that I get is an error message: 'gzip' not recognized as an internal or external command, operable program or batch file. Can anybody tell me how to fix this?

I'm running on:

R version 3.6.0 (2019-04-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17134)

Matrix products: default

[1] LC_COLLATE=Portuguese_Brazil.1252  LC_CTYPE=Portuguese_Brazil.1252    
LC_MONETARY=Portuguese_Brazil.1252 LC_NUMERIC=C                       

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

other attached packages:
[1] R.utils_2.9.0      R.oo_1.22.0        R.methodsS3_1.7.1  getCRUCLdata_0.3.0 
raster_2.9-5       sp_1.3-1          

loaded via a namespace (and not attached):
[1] Rcpp_1.0.1        lattice_0.20-38   codetools_0.2-16  digest_0.6.19     
hoardr_0.5.2      rappdirs_0.3.1    grid_3.6.0        R6_2.4.0          
data.table_1.12.2 rgdal_1.4-3       tools_3.6.0      
[12] compiler_3.6.0   

Alternatively, I would like to know how to convert the .dat file, obtained by decompressing the file downloadable from the link in the example, to a raster stack.


Code in that package uses gzip to decompress the .gz file:

   wvar <- data.frame(data.table::fread(cmd = paste0("gzip -dc ", 
        files[[1]]), header = FALSE))

gzip is a standard utility with Linux but must be an optional extra for Windows that you don't have, or R isn't finding the gzip binary executable.

Its possible that R code should use the value of the R_GZIPCMD environment variable instead of expecting it in the search path. Perhaps you should file an issue on the package to replace their explicit fread(cmd="gzip....") with something that gets the gzip command from this variable:

> message(Sys.getenv("R_GZIPCMD"))
/bin/gzip -n
  • Thanks, @Spacedman. The interesting situation is that I, indeed, can use gzip out from create_CRU_stack... too strange – perep1972 Jul 27 at 14: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.