I'm happy to hear you are finding the library useful! If you are using
netcdf-java 4.6.x, I would recommend using the grid feature type, which
sits at the highest level of the CDM API:
Under the "Using a GridDataset" section, there is an example of how to read
the value of a grid given a specific lat/lon.
Sean Arms, PhD
On Tue, Jun 18, 2019 at 10:38 AM Harold <harold@xxxxxxxxxxxxxx> wrote:
> 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:
> 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
> 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,
> NOTE: All exchanges posted to Unidata maintained email lists are
> recorded in the Unidata inquiry tracking system and made publicly
> available through the web. Users who post to any of the lists we
> maintain are reminded to remove any personal information that they
> do not want to be made public.
> netcdf-java mailing list
> For list information or to unsubscribe, visit: