NSF Unidata

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.



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