El 13/03/13 10:14, Andrea Aime escribió:
On Wed, Mar 13, 2013 at 9:47 AM, PabloDR <pablo.labor...@gmail.com <mailto:pablo.labor...@gmail.com>> wrote:

    I've done something similar to get noData, min and max values:

        private static SortedSet<Double> removeNoDataFromArray(double[]
    data, Double NoData){
             SortedSet<Double> set = CollectionFactory.sortedSet();
             Double[] array = ArrayUtils.toObject(data);
             set.addAll(Arrays.asList(array));
             while (set.remove(NoData));
             return set;
         }
         private static double[] getDataFromCoverage(GridCoverage2D
    coverage){
             Raster raster = coverage.getRenderedImage().getData();
             double data[] = new
    double[raster.getHeight()*raster.getWidth()];
             data = raster.getPixels(raster.getMinX(), raster.getMinY(),
    raster.getWidth(), raster.getHeight(), data);
             return data;
         }
         public static double getMaxValue(GridCoverage2D coverage){
             Double NoData = getNoDataValue(coverage);
             double data[] = getDataFromCoverage(coverage);
             SortedSet<Double> set = removeNoDataFromArray(data, NoData);
             return set.last();
         }
         public static double getMinValue(GridCoverage2D coverage){
             Double NoData = getNoDataValue(coverage);
             double data[] = getDataFromCoverage(coverage);
             SortedSet<Double> set = removeNoDataFromArray(data, NoData);
             return set.first();
         }
         public static Double getNoDataValue(GridCoverage2D coverage){
             Double NoData = (Double)coverage.getProperty("GC_NODATA");
             return NoData;
         }


I can see them being added either to a utility class or to GridCoverage2D itself,
but implemented this way they cannot be added to GeoTools:
- they have no support for multiband coverages
- they read all the coverage in memory, which is a no-go, some readers easily handle coverages of hundreds of gigabytes in size... this has to be implemented either as a JAI operation (a NODATA aware Extrema), or using tile oriented access to the RenderedImage inside the coverage, so that only a chunk of the data at a time is
  loaded in memory

I mean, geotools base library should implement the methods getMax, getMin and getNoDataValue, but not the methods I wrote, because, in fact, these methods are incomplete and runs well only in a few ways.

Thanks Andrea.
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to