0

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.

  • I don't see any error for the process, so did the output not work? (the lookup UOM thing probably doesn't matter). Your "RAIN_MM_1hour_ac_proj.nc" is a GeoTIFF, since you didn't specify the output format with "-of NetCDF" (GDAL doesn't care about extensions, but helpfully reminded you). Why are you trying to warp a file that's pretty clearly in Long-Lat to Long-Lat? I don't understand why you have any work to do here (??). You maybe want to gdal_translate with -a_srs argument to fill in the metadata. – mdsumner Feb 5 '16 at 15:05
  • @mdsummer Thank you for the part with the output format, I didn't know that GDAL ignores the extensions. My question derived from this post, which gives me headaches, too. The 404 Error (+ pink tiles) appears only when I pan the map to the west of Africa (not where my data should overlay), so I suppose the problem has something to do with the projection. I thought I'd deal with the projection and then with the Not found error. I'll come back with the outcome. – Ralu Bur Feb 5 '16 at 15:25
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.