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.

[THREDDS #HZJ-336154]: Fwd: Re: Web Services to NAM12K

At that point you need to look at the coordinate arrays, which are in 
projection units.

You might find ucar.nc2.dt.grid.GridCoordSystem useful:

  /**
   * Given a point in x,y coordinate space, find the x,y index in the 
coordinate system.
   * Not implemented yet for 2D.
   *
   * @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. 
These will be -1 if out of range.
   */
  public int[] findXYindexFromCoord( double x_coord, double y_coord, int[] 
result) {
    if (result == null)
      result = new int[2];

    if ((horizXaxis instanceof CoordinateAxis1D) && (horizYaxis instanceof 
CoordinateAxis1D)) {
      result[0] = ((CoordinateAxis1D) horizXaxis).findCoordElement(x_coord);
      result[1] = ((CoordinateAxis1D) horizYaxis).findCoordElement(y_coord);
      return result;
    } else if ((horizXaxis instanceof CoordinateAxis2D) && (horizYaxis 
instanceof CoordinateAxis2D)) {
      result[0] = -1;
      result[1] = -1;
      return result;
      //return ((CoordinateAxis2D) xaxis).findXYindexFromCoord( xpos, ypos, 
result);
    }

    // cant happen
    throw new IllegalStateException("GridCoordSystem.findXYindexFromCoord");
  }

if you want to use it, open the dataset with ucar.nc2.dt.grid.GridDataset. More 
info at:

http://www.unidata.ucar.edu/software/netcdf-java/tutorial/GridDatatype.html

Ticket Details
==================
Ticket ID: HZJ-336154
Department: Support THREDDS
Priority: Emergency
Status: Open


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