Class GridRasterWrapper


  • public class GridRasterWrapper
    extends Object
    Wrapper to convert org.openjump.core.rasterimage.sextante.OpenJUMPSextanteRasterLayer to 2D Array (Matrix) or to a 1D Array.
    Author:
    Giuseppe Aruta [2018-05-18]
    • Constructor Detail

      • GridRasterWrapper

        public GridRasterWrapper()
    • Method Detail

      • rasterToMatrix

        public static double[][] rasterToMatrix​(OpenJUMPSextanteRasterLayer rstLayer,
                                                int band)
        Convert a OpenJUMPSextanteRasterLayer to a 2D Array as double
        Parameters:
        rstLayer - OpenJUMP Sextante Raster Layer
        band - (integer)
        Returns:
        the matrix representing this Raster as a 2-dimensional double array
      • rasterToEmptyMatrix

        public static double[][] rasterToEmptyMatrix​(OpenJUMPSextanteRasterLayer rstLayer,
                                                     int band)
        create an empty 2D Array from a OpenJUMPSextanteRasterLayer
        Parameters:
        rstLayer - OpenJUMP Sextante Raster Layer
        band - (integer)
        Returns:
        a 2-dimensional double array sized after this raster and filled with nodata values
      • rasterToMatrix

        public static double[][] rasterToMatrix​(OpenJUMPSextanteRasterLayer rstLayer)
        Convert the first band of OpenJUMPSextanteRasterLayer to a 2D Array as double Useful for single banded raster
        Parameters:
        rstLayer - OpenJUMP Sextante Raster Layer
        Returns:
        the matrix representing this OpenJUMPSextanteRasterLayer as a 2-dimensional double array
      • rasterToArray

        public static double[] rasterToArray​(OpenJUMPSextanteRasterLayer rstLayer,
                                             int band)
        Convert the first band of OpenJUMPSextanteRasterLayer to a 1D Array as double
        Parameters:
        rstLayer - OpenJUMPSextanteRasterLayer to convert to a double array
        band - the Raster band to export
        Returns:
        a 1-dimensional double array containing all the OpenJUMPSextanteRasterLayer values contained in a band
      • rasterToArray

        public static double[] rasterToArray​(OpenJUMPSextanteRasterLayer rstLayer)
        Convert the first band of OpenJUMPSextanteRasterLayer to a 1D Array as double Useful for single banded raster
        Parameters:
        rstLayer - OpenJUMP Sextante Raster Layer
        Returns:
        a 1-dimensional double array containing all OpenJUMPSextanteRasterLayer values contained in band 0
      • rasterToArray

        public static double[] rasterToArray​(OpenJUMPSextanteRasterLayer rstLayer,
                                             int band,
                                             double min,
                                             double max)
        Convert a band of OpenJUMPSextanteRasterLayer to a 1D Array as double. Limit the array to min/max values
        Parameters:
        rstLayer - OpenJUMP Sextante Raster Layer
        band - the Raster band to analyze
        min - minimum value to copy
        max - maximum value to copy
        Returns:
        a 1-dimensional double array containing all the Raster values for this band which are strictly higher than min and lower than max
      • rasterToArray

        public static double[] rasterToArray​(OpenJUMPSextanteRasterLayer rstLayer,
                                             double min,
                                             double max)
        Convert the first band of of OpenJUMPSextanteRasterLayer to a 1D Array as double. Limit the array to min/max values
        Parameters:
        rstLayer - OpenJUMP Sextante Raster Layer
        min - minimum value to copy
        max - maximum value to copy
        Returns:
        a 1-dimensional double array containing all the Raster values for band 0 which are strictly higher than min and lower than max
      • matrixToRaster

        public static Raster matrixToRaster​(double[][] matrix,
                                            SampleModel model)
        Convert a 2DArray (Matrix) as double to java.awt.image.Raster, to band 0
        Parameters:
        matrix - 2D Array as double
        model - Sample Model
        Returns:
        java.awt.image.Raster
      • matrixToRaster

        public static Raster matrixToRaster​(double[][] matrix,
                                            SampleModel model,
                                            int band)
        Convert a 2DArray (Matrix) as double to java.awt.image.Raster, defining the band number
        Parameters:
        matrix - 2D Array as double
        model - Sample Model
        band - number
        Returns:
        java.awt.image.Raster
      • rasterToMatrix

        public static double[][] rasterToMatrix​(Raster raster)
        Convert a java.awt.image.Raster to 2DArray (Matrix) as double
        Parameters:
        raster - input raster
        Returns:
        2DArray (Matrix) as double[][]
      • matrixToRaster

        public static WritableRaster matrixToRaster​(double[][] matrix)
        Convert a double 2DArray (matrix) to java.awt.image.WritableRaster (single band)
        Parameters:
        matrix - 2D double Array
        Returns:
        WritableRaster