ssh - Reading netCDF files stored on a remote filesystem in R? -
i need read netcdf file r stored on remote filesystem. have ssh access filesystem, files big store onto local computer.
i have tried advice here: can r read file through ssh connection? tried following:
library(ncdf) d = open.ncdf(pipe('ssh hostname "path/to/file/foo.nc"'))
however, keep getting error
bash: path/to/file/foo.nc: permission denied
any ideas on how fix this?
it not possible open file directly within r using ssh, there few options available you.
1. mount remote server local filesystem on ssh.
there packages let mount remote machines local filesystems on ssh; on linux, example, might use sshfs
whereas on windows might use win-sshfs
. once you've mounted remote file system, able access netcdf files r other file, although i'm not sure performance implications may be.
- ssh(sftp) filesystem windows: http://code.google.com/p/win-sshfs/
- ssh filesystem: http://fuse.sourceforge.net/sshfs.html
2. break larger files down smaller files.
use command-line ncdump
utility, on server, create smaller files large files able fit on local file system.
$ ncdump -v [var1],[var2] big.nc > smaller.cdl
smaller.cdl text file; can generate binary netcdf .nc
file using ncgen
:
$ ncgen -b -o smaller.nc smaller.cdl
- examples of ncdump usage may found here: http://www.unidata.ucar.edu/software/netcdf/workshops/2012/utilities/ncdumpexamples.html2.
3. use opendap service on remote server.
unless remote server set provide opendap service, overkill. if is, may use combination of r's opendap access , netcdf's opendap subset service retrieve data subsets on fly. can use ncdump
on local machine request subset of data server.
- accessing netcdf/opendap data r: https://publicwiki.deltares.nl/display/oet/opendap+access+with+r
Comments
Post a Comment