Tom,

ncdf files are indeed recognized by their extension (".NC",".CDF", ".NCDF",
".NETCDF"). I might add further checks that do not depend on the extension.
However,  this should work

> raster('./METCRO3D_080101.nc', varname='ZF')

if a file with than name (and extension) exists AND if you the ncdf or
ncdf4 package is available AND if a somewhat standard organization of the
values is used (CF convention). I suspect your problem may be the second
part of the clause.

Robert



On Sun, Feb 10, 2013 at 11:40 AM, Tom Roche <Tom_Roche@pobox.com> wrote:

>
> I'm trying to create an extents object from a large netCDF file on a
> linux cluster running RHEL 5.4. I'd try to make the file publicly
> available, but
>
> $ ls -alh ./METCRO3D_080101
> -r--r--r-- 1 me mygroup 5.3G Jan  8 11:32 ./METCRO3D_080101
>
> # extension used below
> $ ln -s ./METCRO3D_080101 ./METCRO3D_080101.nc
>
> # note netCDF-ness of file, and existence of datavar=ZF
> $ ncdump -v ZF ./METCRO3D_080101 | head
> netcdf METCRO3D_080101 {
> dimensions:
>         TSTEP = UNLIMITED ; // (25 currently)
>         DATE-TIME = 2 ;
>         LAY = 24 ;
>         VAR = 17 ;
>         ROW = 299 ;
>         COL = 459 ;
> variables:
>         int TFLAG(TSTEP, VAR, DATE-TIME) ;
> $ ncdump -v ZF ./METCRO3D_080101 | tail
>     19116.16, 19112.75, 19128.86, 19171.77, 19206.04, 19224.66, 19247.3,
>     19293.71, 19343.23, 19370.01, 19386.64, 19389.33, 19391.63, 19417.19,
>     19442.12, 19456.19, 19471.03, 19481.76, 19485.71, 19492.51, 19501.67,
>     19511.11, 19499.88, 19470.57, 19464.8,  19466.73, 19467.94, 19481.03,
>     19502.62, 19534.05, 19562.75, 19607.45, 19659.45, 19687.44, 19706.39,
>     19735.43, 19790.02, 19842.22, 19862.31, 19867.04, 19871.75, 19876.44,
>     19881.59, 19882.53, 19838.23, 19772.65, 19724.43, 19754.49, 19824.58,
>     19852.86, 19897.51, 19921.67, 19909.53, 19925.96, 19937.74, 19940.95,
>     19944.61, 19948.7,  19953.03, 19957.13 ;
> }
>
> $ R
> R version 2.15.2 (2012-10-26) -- "Trick or Treat"
> Copyright (C) 2012 The R Foundation for Statistical Computing
> ISBN 3-900051-07-0
> Platform: x86_64-unknown-linux-gnu (64-bit)
>
> ...
>
> > library(raster)
> Loading required package: sp
> raster 2.0-41 (21-December-2012)
> > system('ls -alh ./METCRO3D_080101')
> -r--r--r-- 1 me mygroup 5.3G Jan  8 11:32 ./METCRO3D_080101
> > system('ls -alh ./METCRO3D_080101.nc')
> lrwxrwxrwx 1 me mygroup 17 Feb 10 13:46 ./METCRO3D_080101.nc ->
> ./METCRO3D_080101
> > raster('./METCRO3D_080101', varname='ZF')
> rgdal: version: 0.8-4, (SVN revision 431)
> Geospatial Data Abstraction Library extensions to R successfully loaded
> Loaded GDAL runtime: GDAL 1.7.3, released 2010/11/10
> Path to GDAL shared files: /usr/local/share/gdal
> GDAL does not use iconv for recoding strings.
> Loaded PROJ.4 runtime: Rel. 4.8.0, 6 March 2012, [PJ_VERSION: 480]
> Path to PROJ.4 shared files: (autodetected)
> Error in .local(.Object, ...) :
>   `/home/rtd/code/regridding/MOZART_global_to_AQMEII-NA/METCRO3D_080101'
> not recognised as a supported file format.
>
>
> Error in .rasterObjectFromFile(x, band = band, objecttype = "RasterLayer",
>  :
>   Cannot create a RasterLayer object from this file.
>
> # Thinking that `raster` might want a supported extension to convince
> # it of the file's netCDF-ness, I tried
>
> > raster('./METCRO3D_080101.nc', varname='ZF')
> Error in .local(.Object, ...) :
>   `.../METCRO3D_080101' not recognised as a supported file format.
>
>
> Error in .rasterObjectFromFile(x, band = band, objecttype = "RasterLayer",
>  :
>   Cannot create a RasterLayer object from this file.
>
> But plainly `ncdump` thinks METCRO3D_080101 *is* netCDF.
> Can I convince `raster`? Either way, how to proceed?
>
> Your assistance is appreciated, Tom Roche <Tom_Roche@pobox.com>
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

	[[alternative HTML version deleted]]

