public Point readData(GridDatatype grid, CalendarDate date, double lat, double lon) throws java.io.IOException { GridCoordSystem gcs = grid.getCoordinateSystem(); //CoordinateAxis1DTime timeAxis = gcs.getTimeAxis1D(); //int tidx = timeAxis.findTimeIndexFromCalendarDate(date); int tidx =-1; //Date may be null if the grid does not have time axis if(date != null) tidx = findTimeIndexForCalendarDate(gcs, date); //int[] xy = gcs.findXYindexFromLatLonBounded(lat, lon, null); int[] xy = gcs.findXYindexFromLatLon(lat, lon, null); Array data = grid.readDataSlice(tidx, -1, xy[1], xy[0]); // use actual grid midpoint LatLonPoint latlon = gcs.getLatLon(xy[0], xy[1]); Point p = new Point(); p.lat = latlon.getLatitude(); p.lon = latlon.getLongitude(); p.dataValue = data.getDouble( data.getIndex()); return p; }
System.out.println("Y increment : " + ((CoordinateAxis1D) gcs.getYHorizAxis()).getIncrement()); LatLonPoint p = gcs.getLatLon(0, 0); System.out.println("index (0,0) --> lat/lon : " + p.getLatitude() + " ; " + p.getLongitude()); p = gcs.getLatLon(1, 1); System.out.println("index (1,1) --> lat/lon : " + p.getLatitude() + " ; " + p.getLongitude()); System.out.println("Y increment : " + ((CoordinateAxis1D) gcs2.getYHorizAxis()).getIncrement()); p = gcs2.getLatLon(0, 0); System.out.println("index (0,0) --> lat/lon : " + p.getLatitude() + " ; " + p.getLongitude()); p = gcs2.getLatLon(1, 1); System.out.println("index (1,1) --> lat/lon : " + p.getLatitude() + " ; " + p.getLongitude());
public Point readData(GridDatatype grid, CalendarDate date, double lat, double lon) throws java.io.IOException { GridCoordSystem gcs = grid.getCoordinateSystem(); //CoordinateAxis1DTime timeAxis = gcs.getTimeAxis1D(); //int tidx = timeAxis.findTimeIndexFromCalendarDate(date); int tidx =-1; //Date may be null if the grid does not have time axis if(date != null) tidx = findTimeIndexForCalendarDate(gcs, date); //int[] xy = gcs.findXYindexFromLatLonBounded(lat, lon, null); int[] xy = gcs.findXYindexFromLatLon(lat, lon, null); Array data = grid.readDataSlice(tidx, -1, xy[1], xy[0]); // use actual grid midpoint LatLonPoint latlon = gcs.getLatLon(xy[0], xy[1]); Point p = new Point(); p.lat = latlon.getLatitude(); p.lon = latlon.getLongitude(); p.dataValue = data.getDouble( data.getIndex()); return p; }
public Point readData(GridDatatype grid, CalendarDate date, double lat, double lon) throws java.io.IOException { GridCoordSystem gcs = grid.getCoordinateSystem(); //CoordinateAxis1DTime timeAxis = gcs.getTimeAxis1D(); //int tidx = timeAxis.findTimeIndexFromCalendarDate(date); int tidx =-1; //Date may be null if the grid does not have time axis if(date != null) tidx = findTimeIndexForCalendarDate(gcs, date); //int[] xy = gcs.findXYindexFromLatLonBounded(lat, lon, null); int[] xy = gcs.findXYindexFromLatLon(lat, lon, null); Array data = grid.readDataSlice(tidx, -1, xy[1], xy[0]); // use actual grid midpoint LatLonPoint latlon = gcs.getLatLon(xy[0], xy[1]); Point p = new Point(); p.lat = latlon.getLatitude(); p.lon = latlon.getLongitude(); p.dataValue = data.getDouble( data.getIndex()); return p; }
public Point readData(GridDatatype grid, CalendarDate date, double zCoord, double lat, double lon) throws java.io.IOException { GridCoordSystem gcs = grid.getCoordinateSystem(); //CoordinateAxis1DTime timeAxis = gcs.getTimeAxis1D(); //int tidx = timeAxis.findTimeIndexFromCalendarDate(date); int tidx = -1; //Date may be null if the grid does not have time axis if(date != null) tidx= findTimeIndexForCalendarDate(gcs, date); CoordinateAxis1D zAxis = gcs.getVerticalAxis(); int zidx = zAxis.findCoordElement( zCoord); int[] xy = gcs.findXYindexFromLatLon(lat, lon, null); Array data = grid.readDataSlice(tidx, zidx, xy[1], xy[0]); // use actual grid midpoint LatLonPoint latlon = gcs.getLatLon(xy[0], xy[1]); Point p = new Point(); p.lat = latlon.getLatitude(); p.lon = latlon.getLongitude(); p.z = zAxis.getCoordValue( zidx); p.dataValue = data.getDouble( data.getIndex()); return p; }
public Point readData(GridDatatype grid, CalendarDate date, double zCoord, double lat, double lon) throws java.io.IOException { GridCoordSystem gcs = grid.getCoordinateSystem(); //CoordinateAxis1DTime timeAxis = gcs.getTimeAxis1D(); //int tidx = timeAxis.findTimeIndexFromCalendarDate(date); int tidx = -1; //Date may be null if the grid does not have time axis if(date != null) tidx= findTimeIndexForCalendarDate(gcs, date); CoordinateAxis1D zAxis = gcs.getVerticalAxis(); int zidx = zAxis.findCoordElement( zCoord); int[] xy = gcs.findXYindexFromLatLon(lat, lon, null); Array data = grid.readDataSlice(tidx, zidx, xy[1], xy[0]); // use actual grid midpoint LatLonPoint latlon = gcs.getLatLon(xy[0], xy[1]); Point p = new Point(); p.lat = latlon.getLatitude(); p.lon = latlon.getLongitude(); p.z = zAxis.getCoordValue( zidx); p.dataValue = data.getDouble( data.getIndex()); return p; }
public Point readData(GridDatatype grid, CalendarDate date, double zCoord, double lat, double lon) throws java.io.IOException { GridCoordSystem gcs = grid.getCoordinateSystem(); //CoordinateAxis1DTime timeAxis = gcs.getTimeAxis1D(); //int tidx = timeAxis.findTimeIndexFromCalendarDate(date); int tidx = -1; //Date may be null if the grid does not have time axis if(date != null) tidx= findTimeIndexForCalendarDate(gcs, date); CoordinateAxis1D zAxis = gcs.getVerticalAxis(); int zidx = zAxis.findCoordElement( zCoord); int[] xy = gcs.findXYindexFromLatLon(lat, lon, null); Array data = grid.readDataSlice(tidx, zidx, xy[1], xy[0]); // use actual grid midpoint LatLonPoint latlon = gcs.getLatLon(xy[0], xy[1]); Point p = new Point(); p.lat = latlon.getLatitude(); p.lon = latlon.getLongitude(); p.z = zAxis.getCoordValue( zidx); p.dataValue = data.getDouble( data.getIndex()); return p; }
int[] xy = gcs.findXYindexFromLatLonBounded(location.getLatitude(), location.getLongitude(), null); LatLonPoint latlon = gcs.getLatLon(xy[0], xy[1]); Point p = new Point(); p.lat = latlon.getLatitude();
int[] xy = gcs.findXYindexFromLatLonBounded(location.getLatitude(), location.getLongitude(), null); LatLonPoint latlon = gcs.getLatLon(xy[0], xy[1]); Point p = new Point(); p.lat = latlon.getLatitude();
LatLonPoint latlon = gcs.getLatLon(xy[0], xy[1]);
LatLonPoint latlon = gcs.getLatLon(xy[0], xy[1]);
LatLonPoint latlon = gcs.getLatLon(xy[0], xy[1]);
int[] xy = gcs.findXYindexFromLatLonBounded(location.getLatitude(), location.getLongitude(), null); LatLonPoint latlon = gcs.getLatLon(xy[0], xy[1]); Point p = new Point(); p.lat = latlon.getLatitude();
/** * Test GridCoordSystem.getLatLon() * * @throws IOException if ... * @throws InvalidRangeException if ... */ @Test public void checkGridCoordSystem_getLatLon() throws IOException, InvalidRangeException { int[] origin = new int[] { j, i}; int[] shape = new int[] {1,1}; NetcdfFile ncf = NetcdfFile.open( datasetLocation); Variable latVar = ncf.findVariable( "lat" ); Array latArray = latVar.read( origin, shape ); Variable lonVar = ncf.findVariable( "lon" ); Array lonArray = lonVar.read( origin, shape ); double latVal = latArray.getDouble( latArray.getIndex()); double lonVal = lonArray.getDouble( lonArray.getIndex()); GridDataset gd = GridDataset.open( datasetLocation ); GeoGrid gg = gd.findGridByName( "hs" ); GridCoordSystem gridCoordSys = gg.getCoordinateSystem(); //gridCoordSys.getXHorizAxis().; //gridCoordSys.getYHorizAxis(); LatLonPoint llPnt = gridCoordSys.getLatLon( 170, 62 ); Assert.assertEquals( lat, llPnt.getLatitude(), 0.001 ); Assert.assertEquals( lon, llPnt.getLongitude(), 0.001 ); }