Permission denied on opening .nc file

I load the necessary library (ncdf4) and directed the right path but I don't know why it is having permission denied to open it:
nc = nc_open('temp.nc')

Error:
Error in R_nc4_open: Permission denied

I found a similar question in this group (Problem while opening netcdf file in Rstudio 3.6.2), but it is closed and has no needful information in it.

Looking for kind suggestions.
Many thanks.

I'm not familiar with {ncdf4}, but as in the cited thread I would start with looking for obvious file problems.

What happens if you run this?

readLines('temp.nc')

If you get a result like

1] "CDF\001"    ""           "_FillValue" "Population" ""          
[6] ""          
Warning messages:
1: In readLines("temp.nc") :
  line 1 appears to contain an embedded nul

that suggests the failure is at the ncdf4 level, whereas if you get the same Permission denied error (or can't open the connection) that suggests it's at the OS level, e.g. the path is incorrect or something.

Also, what is your Operating System, and version of R?

Thank you @AlexisW
I figured out that Onedrive somehow was disconnected leading to that error. It is now solved.
Thanks lot.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.