[GIS] Project NetCDF file using GDAL or QGis

coordinate systemgdalnetcdf

Can I project a NetCDF file with the help of GDAL or QGis?
The file info is:

gdalinfo c:\tomcat-6.0.36\webapps\ncWMS\layers\RAIN_MM_1hour_ac.nc
Driver: netCDF/Network Common Data Format
Files: c:\tomcat-6.0.36\webapps\ncWMS\layers\RAIN_MM_1hour_ac.nc
Size is 772, 668
Coordinate System is `'
Origin = (19.980464188539599,49.004338539807151)
Pixel Size = (0.012931622920800,-0.008983060104580)
Metadata:
  lat#long_name=latitude
  lat#standard_name=latitude
  lat#units=degrees_north
  lon#long_name=longitude
  lon#standard_name=longitude
  lon#units=degrees_east
  NC_GLOBAL#Conventions=CF-1.5
  NC_GLOBAL#GDAL=GDAL 1.11.2, released 2015/02/10
  NETCDF_DIM_EXTRA={Time}
  NETCDF_DIM_Time_DEF={1,6}
  NETCDF_DIM_Time_VALUES=0
  RAIN_MM_1hour_ac#_FillValue=0
  RAIN_MM_1hour_ac#long_name=GDAL Band Number 1
  RAIN_MM_1hour_ac#units=mm
  Time#units=hours since 2014-10-01 00:00:00
Corner Coordinates:
Upper Left  (  19.9804642,  49.0043385)
Lower Left  (  19.9804642,  43.0036544)
Upper Right (  29.9636771,  49.0043385)
Lower Right (  29.9636771,  43.0036544)
Center      (  24.9720706,  46.0039965)
Band 1 Block=772x1 Type=Float64, ColorInterp=Undefined
  NoData Value=0
  Metadata:
    _FillValue=0
    long_name=GDAL Band Number 1
    NETCDF_DIM_Time=0
    NETCDF_VARNAME=RAIN_MM_1hour_ac
    units=mm

Using gdalwarp

gdalwarp -t_srs '+proj=lonlat +datum=WGS84 +no_defs' 
 c:/tomcat-6.0.36/webapps/ncWMS/layers/RAIN_MM_1hour_ac.nc 
 c:/tomcat-6.0.36/webapps/ncWMS/layers/RAIN_MM_1hour_ac_proj.nc

results in:

ERROR 1: Failed to lookup UOM CODE 0
Warning: The target file has a 'nc' extension, 
which is normally used by the GMT, netCDF drivers,
but the requested output driver is GTiff. Is it really what you want ?

I tried to save the file in QGis with the specified projection (EPSG:4326), but the output file is limited to a GeoTiff format.

I want the output data to also be in NetCDF format, in order to serve it to an OpenLayers map through ncWMS.

PS: I am not familiar with R or Python yet, so I would like an approach using the above mentioned software.

Best Answer

As mdsummer pointed out, you need to give it the output driver to use, in your case: -of netCDF:

gdalwarp -t_srs '+proj=lonlat +datum=WGS84 +no_defs' -of netCDF c:/tomcat-6.0.36/webapps/ncWMS/layers/RAIN_MM_1hour_ac.nc c:/tomcat-6.0.36/webapps/ncWMS/layers/RAIN_MM_1hour_ac_proj.nc

It's also clearer IMO to use t_srs EPSG:4326 rather than an (incomplete) Proj4 string if you want output in WGS84.