[R-sig-Geo] NetCDF and raster on MAC
Robert J. Hijmans
r.hijmans at gmail.com
Mon Aug 23 01:31:00 CEST 2010
Dear Steven, Thank you. You are using version 1.3-4. You need 1.3-11
(form CRAN) or higher (from R-Forge). Best, Robert
On Sun, Aug 22, 2010 at 4:27 PM, steven mosher <moshersteven at gmail.com> wrote:
> Thanks Robert.
> raster has been a great tool for me and others working on the same problem.
> I had tried what you suggested that which lead to the error message. see
> nc = open.ncdf(seafile, write = FALSE)
>  "id" "ndims" "natts" "unlimdimid" "filename"
> "varid2Rindex" "writable" "dim" "nvars"
>  "var"
>  72 36 1927
> Loading required package: RNetCDF
> Error in .rasterObjectFromCDF(x, type = objecttype, band = band, ...) :
> You need to install the RNetCDF package first
> R version 2.11.1 (2010-05-31)
>  en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
> attached base packages:
>  stats graphics grDevices utils datasets methods base
> other attached packages:
>  ncdf_1.6 uncompress_1.33 R.utils_1.4.4 R.oo_1.7.3
> R.methodsS3_1.2.0 zoo_1.6-3 maps_2.1-4 raster_1.3-4
>  sp_0.9-66
> loaded via a namespace (and not attached):
>  grid_2.11.1 lattice_0.18-8 tools_2.11.1
> On Sun, Aug 22, 2010 at 4:02 PM, Robert J. Hijmans <r.hijmans at gmail.com>
>> 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')
>> Hth, Robert
>> On Sun, Aug 22, 2010 at 12:14 PM, steven mosher <moshersteven at gmail.com>
>> > 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