Re: [netcdf-java] Data from Lat Lon in 4.3

Hi Cameron:

Im not seeing a problem with the files you sent in the latest code. Can you download 4.3.9rc1 from

http://www.unidata.ucar.edu/software/netcdf-java/documentation.htm#v43

and try again? Note that the variable names have all changed - could that be the problem?

other answers are below

On 2/20/2012 8:50 AM, Cameron Fraser wrote:
Following on from previous post to obtain a data for a given lat/lon, the provided code sample worked in 4.2 but failed in 4.3 ( version switch as recommended for grib use). Error was missing '.rc' file. Found a reference in docs but need guidance as to contents/structure of the file.

My interest in the lat/lon function, and my question after resolving the upgrade issue, is to query a grib file for a specific region. Gribs being used may contain Lambert or lat/lon coordinates. After reading docs, 'findXYindexFromLatLon' will return a value however if either lat or lon is not part of the grid it is ??? (there is no logic provided for how the value returned is determined). Is there a means to enforce the determination or to return the inferred grid value?

from the javadoc:

  /**
* Given a point in x,y coordinate space, find the x,y index in the coordinate system.
   *
   * @param x_coord position in x coordinate space.
   * @param y_coord position in y coordinate space.
   * @param result  put result (x,y) index in here, may be null
* @return int[2], 0=x,1=y indices in the coordinate system of the point. These will be -1 if out of range.
   */
public int[] findXYindexFromCoord(double x_coord, double y_coord, int[] result) {


  /**
* Given a point in x,y coordinate space, find the x,y index in the coordinate system.
   * If outside the range, the closest point is returned
   *
   * @param x_coord position in x coordinate space.
   * @param y_coord position in y coordinate space.
   * @param result  put result in here, may be null
   * @return int[2], 0=x,1=y indices in the coordinate system of the point.
   */
public int[] findXYindexFromCoordBounded(double x_coord, double y_coord, int[] result);

the algorithm is very simple (for the 1D case), it transforms the lat/lon to projection x/y (if needed). Since its 1D , the grid is regular, and it simply locates which cell the x,y is contained in. theres no interpolation or any other ways to do it. The routines differ in what happens if the x,y is not within the grid. findXYindexFromCoord() returns a -1 in one or both indices if not found, findXYindexFromCoordBounded() will return the closest index, ie 0 or n-1 depending on if the coordinate is too small or too large.

the 2D case is more complicated, but you dont seem to have 2D coordinates.


A parallel query is how to obtain a bounding box of actual grid coordinates (nearest neighbours) around a specific lat/lon. From my perspective, this would satisfy the above question, allowing determination of values through appropriate interpolation method.

for a grid, the neighbors in index space are neighbors in coordinate space. so given the index (i,j), neighbors are (i-1,j), (i+1, j),(i,j-1), (i,j+1) if they exist.


Insight, guidance, comments: all are appreciated.

Thanks,
Cameron


_______________________________________________
netcdf-java mailing list
netcdf-java@xxxxxxxxxxxxxxxx
For list information or to unsubscribe, visit: 
http://www.unidata.ucar.edu/mailing_lists/

  • 2012 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: