1

I am trying to work with cordex climatic data (curvelinear and rotated data) in the stars package, and I am having a lot of issues, so decided to simply reproduce online example, and I fail reading in data with the command read_stars.

I am trying reproduce in this post https://github.com/r-spatial/stars/issues/52#issuecomment-430753055 by using the provided data here https://github.com/r-spatial/stars/issues/52#issuecomment-430548580

library(stars)
f = "1-RawData/example_ob_tran.nc" #path to the downloaded file

(r = read_stars(f))

When I do this I am getting

Error in CPL_read_gdal(as.character(x), as.character(options), as.character(driver), : file not found

while the file the following command works

(r = read_ncdf(f))

suggesting that the file exist.

This seems very basic, but I am unable to sort this myself. Does anyone see what I am doing wrong?

1
  • I have the same error under windows with another netcdf file. I think it has nothing to do with variable name but it seems is something windows related (for me, the same code works under linux). github.com/r-spatial/sf/issues/1063 If you find a workaround please let me know. Commented Apr 29, 2020 at 20:23

1 Answer 1

1

Always pay attention to the message appears on the console.

From your code,

library(stars)
f = "1-RawData/example_ob_tran.nc" #path to the downloaded file

(r = read_ncdf(f))

You would have seen this:

stars object with 3 dimensions and 1 attribute
attribute(s):
    tas [K]     
 Min.   :247.0  
 1st Qu.:267.4  
 Median :275.9  
 Mean   :274.5  
 3rd Qu.:282.6  
 Max.   :292.6  
dimension(s):
     from  to offset delta  refsys point                  values    
rlon    1 106     NA    NA      NA    NA  [106] -28.21,...,17.99 [x]
rlat    1 103     NA    NA      NA    NA  [103] -23.21,...,21.67 [y]
time    1   1     NA    NA POSIXct FALSE [1979-01-01,1979-02-01) 

As you see, it has tas attribute (variable). Now read the file again by defining var = "tas".

r = read_ncdf(f, var = "tas")

image(r, axes = TRUE)

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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