/** * Returns a two-element array containing this raster's extreme scalar values, ignoring any values marked as * missing-data. This returns null if this raster contains no values, or if it contains only values marked as * missing-data. * * @return a two-element array containing this raster's extreme values, or null if none exist. Entry 0 contains the * minimum value; entry 1 contains the maximum value. */ public double[] getExtremes() { // Create local variables to store the raster's dimensions and missing data signal to eliminate any overhead in // the loops below. int width = this.getWidth(); int height = this.getHeight(); double missingDataSignal = this.getTransparentValue(); // Allocate a buffer to hold one row of scalar values. double[] buffer = new double[width]; // Allocate a buffer to hold the extreme values. double[] extremes = null; for (int j = 0; j < height; j++) { this.get(0, j, width, buffer, 0); // Get the row starting at (0, j). for (int i = 0; i < width; i++) { if (buffer[i] == missingDataSignal) // Ignore values marked as missing-data. { continue; } if (extremes == null) { extremes = WWUtil.defaultMinMix(); } if (extremes[0] > buffer[i]) { extremes[0] = buffer[i]; } if (extremes[1] < buffer[i]) { extremes[1] = buffer[i]; } } } // Extremes is null if this raster is empty, or contains only values marked as missing-data. return(extremes); }