[R-sig-Geo] NetCDF and raster on MAC

Robert J. Hijmans r.hijmans at gmail.com
Mon Aug 23 01:04:15 CEST 2010


Steven,

The current version of raster (1.3-11 on CRAN) uses 'ncdf' rather then
'RNetCDF'.  The 'ncdf' package is available for OSX.

Then, for a single layer:

r = raster('file.nc')
r = raster('file.nc', band=10)

For all layers:

b = brick('file.nc')

You may get a warning about the variable that was selected. You can
avoid that by explicitly setting the variable you want with the
varname="  " argument, e.g.,

b = brick('file.nc', varname='temperature')

I cannot copy to r-sig-mac, as I am not subscribed to it (that's why
it is bad practice to send a single message to two mailing lists).

Hth, Robert


On Sun, Aug 22, 2010 at 12:14 PM, steven mosher <moshersteven at gmail.com> wrote:
> I'm looking for some examples of how to read a NetCDF file with raster
> directly. The manual is a bit
> terse on the matter. The dats in question is a 3D (lon,lat,time) 72*36, 161
> "bands"
>
> On the MAC I get a request to load RNetCDF, which is not available in
> Binary. I found a few mails
> on geting RNetCDF onto the MAC (and udunits as well)
>
> Failing a direct method, I suppose, I can just read the file into an array
> and the turn that into a multi band
> raster..
>
> TIA
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



More information about the R-sig-Geo mailing list