[R-sig-Geo] problem reading netcdf file with readGDAL: "no bands in dataset"

Michael Sumner mdsumner at gmail.com
Wed Nov 25 21:27:13 CET 2009


There are a number of reasons why GDAL might not be able to read data
from NetCDF, although it might appear to get some metadata upfront.
The 512x512 thing is a default, and to me means that there are
multiple variables in the file, and GDAL requires direct reference to
only one of them as a "subdataset". The syntax is something like this:

NETCDF:"/path/to/filename.nc":varname

If you use gdalinfo at the command line it will tell you the
subdataset strings you can use - the rgdal bindings don't reconstruct
the output that that utility gives you.

Cheers, Mike.

On Thu, Nov 26, 2009 at 12:34 AM, ElenaC <E.Couce.07 at bristol.ac.uk> wrote:
>
> Hi all,
>
> I'm trying to open a netcdf file using the rgdal library, but readGDAL and
> GDALinfo don't seem to be able to correctly access the information in the
> file. It is probably a stupid mistake because I don't understand what I'm
> doing, but I have already spent a long time trying to sort it out and I
> could really use some help with it.
>
> When I try readGDAL, it fails with the error that there are "no bands in
> dataset". This is the output I get from GDALinfo:
>
>> GDALinfo(fname)
> rows        512
> columns     512
> bands       0
> origin.x        0
> origin.y        1
> res.x       1
> res.y       1
> oblique.x   0
> oblique.y   0
> driver      netCDF
> projection  NA
>
> Warning messages:
> 1: In dim(x) : no bands in dataset
> 2: In GDALinfo(fname) : no bands in dataset
>
>
>
> But from opening the file with Panoply, it seems it actually contains four
> variables, two of them 360*180 matrices with the geographical info I'm
> trying to access (global data with 1 degree spatial resolution), and the two
> others called "lat" and "lon" with the latitude and longitude values.
>
> I don't understand why GDALinfo is telling me that the file has 512 rows and
> 512 columns and that there are "no bands". What can I do to access the
> variables I want?
>
> Any help would be greatly appreciated!
> Elena
> --
> View this message in context: http://n2.nabble.com/problem-reading-netcdf-file-with-readGDAL-no-bands-in-dataset-tp4064987p4064987.html
> Sent from the R-sig-geo mailing list archive at Nabble.com.
>
> _______________________________________________
> 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