[gdal-dev] netcd from WRF

Even Rouault even.rouault at spatialys.com
Tue Oct 17 03:26:39 PDT 2017


Hi Vincent,

> 
> I'm trying to visualize **weather forecast data from WRF** in QGIS.
> Ultimately I'd like to add support for viewing/navigating datasets with
> multiple dimensions (Z and time with like sliders to navigate through
> bands).
> 
> gdal recognizes the bands just fine, although the netcdf produced by
> **WRF does not follow netcdf conventions**
> (https://www.ncl.ucar.edu/Applications/wrfnetcdf.shtml)
> 
> The data I have is Lambert93. I was able to add a grid_mapping with
> GeoTransform and spatial_ref using ncap and ncatted (see below for how
> the file is modified to have the crs regognized by gdal)
> 
> The issue I have now is that although the **first band displays
> correctly for a given variable, the folowing bands (corresponding to
> different times) are wrapped** by qgis (which means that the
> geotransform is not recognized properly).

Showing the gdalinfo / ncdump output would have helped better diagnosing.

Are you sure that GDAL handles the bands as GDAL raster bands of the same GDAL 
dataset, and not as different subdatasets (I suspect this is the later) ? 
Because the georeferencing info in a GDAL dataset is attached to the dataset, 
not the bands. So if that works for the first band, that should work for the 
next ones of the same dataset.

In netCDF, the grid_mapping object must be reference by each variable, so that 
each subdataset can find it.
Actually just saw that "gdal_translate multiband.tif multiband.nc -of netCDF" 
only attached the grid_mapping to the first band. Just fixed.

> 
> I think that I could use a vrt, maybe with a python filter, to work
> around the issue, but I'd rather fix the driver if the described
> behavior is considered buggy.
> 
> Questions:
> 
> - is the multiple band model a smart approach for time-varying data ?

Lacking a better abstraction for multidimensional dataset, GDAL cannot do 
better than using bands & subdatasets.

> 
> - shall I try and improve the netcdf driver:
> 
>     - to fix the spatial_ref/geotransform not recognized in bands>1 (if
> fix needed, because I'm not yet sure)

Probably not, if grid_mapping is properly attached to each variable.

> 
>     - to recognize WRF files ? (or is it too specific/no-standard to
> worth it)

Depends on how invasive the changes are and if that doesn't affect behaviour 
with already recognized netCDF datasets, but GDAL mission is to deal with 
real-world datasets, compliant or not to standards.

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list