[geotk] Building a GeographicCRS from scratch

Pablo Rozas Larraondo p.rozas.larraondo at gmail.com
Wed Feb 1 07:15:05 EST 2012


Hello,

I'm working with a Grib file that uses a Lambert Conformal Conic
projection. This projection doesn't correspond to any registered EPSG code
but all the information about the projection is in the descriptor of the
grib file using the standard WMO format (
http://dss.ucar.edu/docs/formats/grib/gribdoc/lcgrid.html).

I suspect that the NetCDF API is capable of processing some of this data
but not all of it. (latitudeOfFirstPointInDegrees doesn't match with the
one I get with NetCDF...)

To solve this issue I'm thinking in using the Geotoolkit API and creating a
GeographicCRS and Conversion objects from scratch to project my file in
cartesian coordinates. There are a lot of attributes in the Grib descriptor
as: uvRelativeToGrid, LoVinDegrees, earthIsOblate, etc. that I somehow have
to translate into parameters of this objects, but I not sure about how to
do it... Does anyone has experience in doing a similar task?


Another issue I've found working with my file is the difference between the
NetCDF and the GeoToolkit API when they read the extreme values of the x&y
axis values. The difference is small but significant, is this normal?

I paste the code I've used and the output I got:

CODE NETCDF API:
NetcdfDataset ds = NetcdfDataset.openDataset("~/myfile.grb");
CoordinateAxis xAxis = ds.findCoordinateAxis("x");
CoordinateAxis yAxis = ds.findCoordinateAxis("x");
System.out.println("BOX2D("+yAxis.getMinValue()+", "+xAxis.getMinValue()+",
"+yAxis.getMaxValue()+", "+xAxis.getMaxValue()+")");

OUTPUT:
BOX2D(-704.9721645900614, -704.9721645900614, 705.0278354099386,
705.0278354099386)


CODE GEOTOOLS API:
NetcdfImageReader netcdfReader = new NetcdfImageReader(null);
netcdfReader.setInput("~/myfile.grb");

ImageCoverageReader reader = new ImageCoverageReader();
reader.setInput(netcdfReader);

GridCoverage2D coverage = reader.read(0, null);
reader.dispose();
netcdfReader.dispose();

System.out.println(coverage.toString());

OUTPUT:
GridCoverage2D["Precipitation_rate", BOX4D(-706.2221645900614
-586.2304882997278 NaN NaN, 706.2778354099386 586.2695117002722 NaN NaN),
NetcdfCRS.Compound["time height_above_ground3 y x"]]
│   RenderedSampleDimension("Precipitation_rate":[])
│       GeophysicsCategory(“No data”:[NaN(-9999…-9999)])
└ Image=WritableRenderedImageAdapter[] as views [NATIVE, PACKED, RENDERED,
GEOPHYSICS, PHOTOGRAPHIC]

Cheers!

Pablo Rozas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/geotoolkit/attachments/20120201/6a4f5a5d/attachment.html


More information about the Geotoolkit mailing list