NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

[netcdf-java] Reading grib2 with LambertConformal_Projection -> lat / lng

Hello,

First, thanks for this lib; it is very helpful and I don't know where we'd
be without it.

I encountered my first netcdf (.grib2) files recently, and hope to access
the data therein to verify the output of another system.

Here's an example file, if that helps:
 - https://s3.us-east-2.amazonaws.com/tech.public.data/grib2-test/3600.grib2

I found PanoplyJ, which works great, and summarizes the file like this:
 - https://i.imgur.com/VJXnpWH.png

I am using the java libs `edu.ucar/cdm` and `edu.ucar/grib`, both at
version 4.6.13 - which also work great and open the file without trouble.

My intention is to verify the contents of this file against a different
dataset which expresses surface location with lat/lng, while this grib2
file has x/y (under a Lambert conformal mapping).

The path I found through the lib yesterday is:
1) NetcdfDataset/openDataset
2) .getVariables and store a reference to the `LambertConformal_Projection`
variable
3) Construct a `LambertConformalConic` and call `.makeCoordinateTransform`
with the dataset and the variable
4) From that I can `.getProjection`
5) Then I make a `float[][]` out of the separate x/y variables
6) Then I can call `.projToLatLon` with the projection and the `float[][]`
7) After this I go linear over the contents of the `Temperature_surface`
variable associating each one with the correct lat/lng.

This actually works, but I am wondering if there is a better way.

I have a feeling that there is some higher level API that I missed that
would do all this more automatically, and possibly more generally. My code
feels brittle and over-specific to this particular file.

Or, put another way, how best to (given a lat/lng) query the temp at that
location in this file?

With warm appreciation for your time,
-Harold
  • 2019 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: