[R-sig-Geo] problem reading netcdf file with readGDAL: "no bands in dataset"
Roger Bivand
Roger.Bivand at nhh.no
Thu Nov 26 21:35:04 CET 2009
On Thu, 26 Nov 2009, ElenaC wrote:
>
> Thanks a lot, Mike!
> I have finally managed to select the subdataset, and everything is working
> now!
In the next release of rgdal, dataset metadata and subdataset names and
descriptions will be reported by GDALinfo() where present, which should
make it easier to follow the advice on:
http://www.gdal.org/frmt_netcdf.html
Roger
>
> Cheers,
> Elena
>
>
>
> Michael Sumner-2 wrote:
>>
>> See this page for more information about the GDAL approach to NetCDF:
>> http://www.gdal.org/frmt_netcdf.html
>>
>> If you can construct the subdataset name correctly then readGDAL
>> should be able to return the given variable, as a single band
>> SpatialGridDataFrame.
>>
>>
>>
>> On Thu, Nov 26, 2009 at 7:27 AM, Michael Sumner <mdsumner at gmail.com>
>> wrote:
>>> 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
>>>>
>>>
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>>
>
> --
> View this message in context: http://n2.nabble.com/problem-reading-netcdf-file-with-readGDAL-no-bands-in-dataset-tp4064987p4071119.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
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo
mailing list