[geotk] NetCDF GridCoverage resampling

Aaron Braeckel braeckel at ucar.edu
Thu Dec 16 23:03:37 EST 2010


Hello,

I have the following code:

    ImageCoverageReader reader = new ImageCoverageReader();
    reader.setInput( TestUtil.readFile( 
"data/GTG_20090721_v_220000_l_0003600.grb" ) );
    CoordinateReferenceSystem targetCRS = CRS.decode( "EPSG:4326" );
    GridCoverage cvg = reader.read( 0, null );
    Coverage resultCvg = Operations.DEFAULT.resample( cvg, targetCRS, 
cvg.getGridGeometry(), Interpolation.getInstance( 
Interpolation.INTERP_NEAREST ) );

This is intended to be a simple re-projection call, and works up to the 
point of Operations.resample().  This call results in:

java.lang.UnsupportedOperationException: Not supported yet.
    at 
org.geotoolkit.referencing.adapters.NetcdfCRS$Projected.getConversionFromBase(NetcdfCRS.java:891)
    at 
org.geotoolkit.referencing.operation.DefaultCoordinateOperationFactory.createOperationStep(DefaultCoordinateOperationFactory.java:961)
    at 
org.geotoolkit.referencing.operation.DefaultCoordinateOperationFactory.createOperation(DefaultCoordinateOperationFactory.java:248)
    at 
org.geotoolkit.referencing.operation.DefaultCoordinateOperationFactory.createOperationStep(DefaultCoordinateOperationFactory.java:1306)
    at 
org.geotoolkit.referencing.operation.DefaultCoordinateOperationFactory.createOperationStep(DefaultCoordinateOperationFactory.java:1181)
    at 
org.geotoolkit.referencing.operation.DefaultCoordinateOperationFactory.createOperation(DefaultCoordinateOperationFactory.java:208)
    at 
org.geotoolkit.referencing.operation.CachingCoordinateOperationFactory.createOperation(CachingCoordinateOperationFactory.java:222)
    at 
org.geotoolkit.referencing.operation.CachingCoordinateOperationFactory.createOperation(CachingCoordinateOperationFactory.java:251)
    at 
org.geotoolkit.coverage.processing.operation.Resampler2D.reproject(Resampler2D.java:361)
    at 
org.geotoolkit.coverage.processing.operation.Resample.doOperation(Resample.java:249)
    at 
org.geotoolkit.coverage.processing.DefaultCoverageProcessor.doOperation(DefaultCoverageProcessor.java:319)
    at 
org.geotoolkit.coverage.processing.CachingCoverageProcessor.doOperation(CachingCoverageProcessor.java:165)
    at 
org.geotoolkit.coverage.processing.Operations.doOperation(Operations.java:788)
    at 
org.geotoolkit.coverage.processing.Operations.resample(Operations.java:458)

It appears that getConversionFromBase() is not yet implemented on 
NetcdfCRS.  Based on my reading of this class, the code seems to be 
lacking the projection detection step from files read via the NetCDF 
API.  In the NetcdfImageReader classes it appears that most of the code 
works at the NetcdfFile/NetcdfDataset level.  I'm not sure if you are 
aware, but the NetCDF API has several high-level feature types, 
including what they call the GridDatatype/GridDataset.  This is a 
higher-level gridded coverage abstraction that allows for reading of 
many different files, including Netcdf 3/4 (multiple conventions), HDF 
(multiple conventions), GRIB 1, GRIB 2, McIdas, etc.  Not all of these 
formats are CF compliant, but the NetCDF API is capable of reading all 
of these formats into GridDatatypes with projection objects and relevant 
metadata.  NetcdfFile objects include semantics related to Variables and 
Attributes, and GridDatatypes interpret these lower-level NetCDF 
concepts into grid types.

It's not completely clear to me whether the existing code is 
intentionally oriented towards only NetCDF formats and the CF/COARDS 
conventions, but the GridDatatype logic in the NetCDF API might be an 
easier way to read gridded information from the large set of formats 
that can be interpreted as grids by the API.  I believe there is a 
relatively straightforward mapping between the projection logic on these 
classes to Geotk projection classes. 

Any thoughts?  I could put some time into implementing portions of this 
logic if that would be productive, or I could take a break from my 
reprojection/resampling task for a couple of weeks.  If this part of 
Geotk is not aimed towards my intended use of NetCDF, another option 
might be for me to implement what I need by making use of the Geotk 
transformation/re-projection logic without the Geotk raster resampling 
logic.  Or perhaps I'm missing something... ;)

Thanks!
Aaron


More information about the Geotoolkit mailing list