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.
Hello Martin, Thank you very much for your help. Your proposal sounds very interesting to me, I didn't know about the Geotoolkit project and it seems to solve a lot of useful tasks like interpolation, transforms, etc. I would like to try the toolkit in my project, I use eclipse IDE and I've installed m2eclipse plugin for working with maven but I don't have much experience with it... If you could give me some basic guidelines to start a project I would really appreciate your help. if you prefer you can reach me at my personal mail: p.rozas.larraondo(at) gmail.com as this particular matter may be out of the netcdf-java mail list purpose. Thanks again. Hello Pablo > > Le 27/01/12 10:14, Pablo Rozas Larraondo a écrit : > > I've succeeded in opening and reading Grib1 files, but I'm having problems > trying > to find out how to access data through lat lon coordinates. In the ECMWF > API there is a function called grib_find_nearest(gid, lat,lon) in which you > give a geocoordinate point and the function returns the value of the closest, > or the four closest grid points. > > Using the NetCDF API I can access the _CoordinateAxisType Attributes of > the grib file which are GeoX and GeoY expressed in Km, but I wonder if > there is a function for accessing values or translating points into > geographic coordinates. > > I'm not sure if the NetCDF API provides API for this task. But one > possible approach may be to use a library which sit on top of the UCAR > NetCDF library. If I use as an example the library which I known (but you > can find other projects doing similar jobs), you could use the > Geotoolkit.org coverage module(http://www.geotoolkit.org/modules/coverage) > like below: > > The read the image, the org.geotoolkit.coverage.io.CoverageIO static > convenience methods should provide an easy start (there is also other > ways if you need more control, for example specifying a subsampling or > the geographic area you want to read). > > GridCoverage coverage = CoverageIO.read("your_file.nc"); > > > It will use the UCAR library under the hood for reading the data. To get > the nearest value of a geodetic coordinate, you can do as below: > > float[] samples = null; > GeneralDirectPosition pos = new GeneralDirectPosition(numberOfDimensions); > // If you have to do a loop, do it here. > pos.setLocation(myOrdinateValues); > samples = coverage.evaluate(pos, samples); > > > Thats it (if everything goes well - I'm actively working on improving the > NetCDF support right now). If the position is not in the same coordinate > reference system than the coverage, the library will do the reprojection > for you. It is also possible to instruct the evaluate method do perform > bilinear or bicubic interpolation automatically. There is also some other > interesting stuff you can get automatically, like exporting the metadata > found in your NetCDF file in an ISO 19139 compliant document. > > Please let me known if you wish to know more. I could then give a more > concrete starting point depending on your environment (e.g. if you use > Maven or not). > > Martin > >
netcdf-java
archives: