Luigi wrote:
I don't seem to be able to import netCDF via r.in.gdal
in grass-6.4.0RC3 osgeo4w version running on XP sp3.
GRASS 6.4.0RC3 (UTM32):C:\ >r.in.gdal
input=SRF_1958.AVG.NC
output=SRF_1958.AVG location=ERA40_SRF
Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute
Location <ERA40_SRF> created
ERROR: Selected band (1) does not exist
Is this something that I should be able to manage to do?
yes
GRASS complains about bands -- the file includes georeferenced
daily climate variables. The file opens OK in viewers such as
Panoply [<http://www.giss.nasa.gov/tools/panoply/>](http://www.giss.nasa.gov/tools/panoply/).
what does the output of gdalinfo look like?
This is what gdalinfo says:
C:\Documents and Settings\Luigi\Desktop>gdalinfo C:\giotto\giotto_data\SRF_195
AVG.NC
Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute
Driver: netCDF/Network Common Data Format
Files: C:\giotto\giotto_data\SRF_1958.AVG.NC
Size is 512, 512
Coordinate System is `’
Metadata:
NC_GLOBAL#domxmin=-1.262909e+001
NC_GLOBAL#domxmax=4.295537e+001
NC_GLOBAL#domymin=2.129965e+001
NC_GLOBAL#domymax=6.144880e+001
NC_GLOBAL#domzmin=1.050000e+003
NC_GLOBAL#domzmax=1.050000e+003
Subdatasets:
SUBDATASET_1_NAME=NETCDF:“C:\giotto\giotto_data\SRF_1958.AVG.NC”:lon
SUBDATASET_1_DESC=[148x158] lon (32-bit floating-point)
SUBDATASET_2_NAME=NETCDF:“C:\giotto\giotto_data\SRF_1958.AVG.NC”:lat
SUBDATASET_2_DESC=[148x158] lat (32-bit floating-point)
SUBDATASET_3_NAME=NETCDF:“C:\giotto\giotto_data\SRF_1958.AVG.NC”:ua
SUBDATASET_3_DESC=[365x148x158] ua (32-bit floating-point)
SUBDATASET_4_NAME=NETCDF:“C:\giotto\giotto_data\SRF_1958.AVG.NC”:va
SUBDATASET_4_DESC=[365x148x158] va (32-bit floating-point)
SUBDATASET_5_NAME=NETCDF:“C:\giotto\giotto_data\SRF_1958.AVG.NC”:drag
SUBDATASET_5_DESC=[365x148x158] drag (32-bit floating-point)
SUBDATASET_6_NAME=NETCDF:“C:\giotto\giotto_data\SRF_1958.AVG.NC”:tg
SUBDATASET_6_DESC=[365x148x158] tg (32-bit floating-point)
SUBDATASET_7_NAME=NETCDF:“C:\giotto\giotto_data\SRF_1958.AVG.NC”:ta
SUBDATASET_7_DESC=[365x148x158] ta (32-bit floating-point)
SUBDATASET_8_NAME=NETCDF:“C:\giotto\giotto_data\SRF_1958.AVG.NC”:qa
SUBDATASET_8_DESC=[365x148x158] qa (32-bit floating-point)
SUBDATASET_9_NAME=NETCDF:“C:\giotto\giotto_data\SRF_1958.AVG.NC”:rt
SUBDATASET_9_DESC=[365x148x158] rt (32-bit floating-point)
SUBDATASET_10_NAME=NETCDF:“C:\giotto\giotto_data\SRF_1958.AVG.NC”:et
SUBDATASET_10_DESC=[365x148x158] et (32-bit floating-point)
SUBDATASET_11_NAME=NETCDF:“C:\giotto\giotto_data\SRF_1958.AVG.NC”:rnfs
SUBDATASET_11_DESC=[365x148x158] rnfs (32-bit floating-point)
SUBDATASET_12_NAME=NETCDF:“C:\giotto\giotto_data\SRF_1958.AVG.NC”:sh
SUBDATASET_12_DESC=[365x148x158] sh (32-bit floating-point)
SUBDATASET_13_NAME=NETCDF:“C:\giotto\giotto_data\SRF_1958.AVG.NC”:lwn
SUBDATASET_13_DESC=[365x148x158] lwn (32-bit floating-point)
SUBDATASET_14_NAME=NETCDF:“C:\giotto\giotto_data\SRF_1958.AVG.NC”:swn
SUBDATASET_14_DESC=[365x148x158] swn (32-bit floating-point)
SUBDATASET_15_NAME=NETCDF:“C:\giotto\giotto_data\SRF_1958.AVG.NC”:lwd
SUBDATASET_15_DESC=[365x148x158] lwd (32-bit floating-point)
SUBDATASET_16_NAME=NETCDF:“C:\giotto\giotto_data\SRF_1958.AVG.NC”:psrf
SUBDATASET_16_DESC=[365x148x158] psrf (32-bit floating-point)
SUBDATASET_17_NAME=NETCDF:“C:\giotto\giotto_data\SRF_1958.AVG.NC”:tamax
SUBDATASET_17_DESC=[365x148x158] tamax (32-bit floating-point)
SUBDATASET_18_NAME=NETCDF:“C:\giotto\giotto_data\SRF_1958.AVG.NC”:tamin
SUBDATASET_18_DESC=[365x148x158] tamin (32-bit floating-point)
SUBDATASET_19_NAME=NETCDF:“C:\giotto\giotto_data\SRF_1958.AVG.NC”:rha
SUBDATASET_19_DESC=[365x148x158] rha (32-bit floating-point)
Corner Coordinates:
Upper Left ( 0.0, 0.0)
Lower Left ( 0.0, 512.0)
Upper Right ( 512.0, 0.0)
Lower Right ( 512.0, 512.0)
Center ( 256.0, 256.0)
It is not clear what the coordinate system info means: is it just unprojected, i.e. I am supposed to import the file to a latlong location in GRASS?
you might try to use gdal_translate extract a single band from
the file and convert it into a GeoTiff. Then import the geotiff
into grass. But anything gdal_translate can read r.in.gdal should
be able to read too (with the right options).
Found out that it is a multi-dataset file:
C:\Documents and Settings\Luigi\Desktop>gdal_translate -of GTiff -b 1 C:\giotto
giotto_data\SRF_1958.AVG.NC SRF_1958.AVG.tiff
Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute
Input file contains subdatasets. Please, select one of them for reading.
Got info on subdatasets following directions at http://www.gdal.org/frmt_netcdf.html
C:\giotto\giotto_data>gdalinfo NETCDF:“SRF_1958.AVG.NC”:tamax
There is one subdataset per climate variable. Each subdataset has one band per day (365 bands). So I translated to geotiff as you suggested.
C:\giotto\giotto_data>gdal_translate -of GTiff -b 1 NETCDF:“SRF_1958.AVG.NC”:tamax SRF_1958.AVG.tiff
I then tried to import in grass the geotiff. It imports and display fine when creating a new location, but no projection info is carried along so no way to use it with other layers/locations in my grass dataset. (by the way r.in.gdal in wxpython gui does not work grass6.4.0-rc3: I used the tcltk gui).
I have also tried to import a single band directly using r.in.gdal: as you pointed out, there is no reason it shouldn’t work if gdal_translate works.
r.in.gdal -e input=NETCDF:“C:\giotto\giotto_data\SRF_1958.AVG.NC”:tamax output=SRF_1958.AVG band=1 location=ERA_40_SRF2
Imports fine but still unable to get projection info, so the data is useless. If Panoply http://www.giss.nasa.gov/tools/panoply/ is able to plot the data on a global coastline, the proj info should be somewhere in the netCDF file: do you have an idea how I can make GRASS aware of the proj info?
Kind regards, many thanks for useful pointers and hints, and sorry for late reply,
Luigi