Class RasterImageIOUtils


  • public class RasterImageIOUtils
    extends Object
    Version:
    1 [2015-03-11]
    Author:
    Giuseppe Aruta - Extension codes to perform some RasterImage Input/Output operations
    • Field Detail

      • defaultNoData

        public static double defaultNoData
    • Constructor Detail

      • RasterImageIOUtils

        public RasterImageIOUtils()
    • Method Detail

      • saveTIF

        public static void saveTIF​(File file,
                                   RasterImageLayer rLayer,
                                   org.locationtech.jts.geom.Envelope envWanted)
                            throws IOException
        Export selected raster to TIF/TFW - using JAI TiffEncoder.class
        Parameters:
        file - file to save es D:/Openjump/test.tif
        rLayer - Selected Raster Image Layer (RasterImageLayer.class)
        envWanted - envelope wanted
        Throws:
        IOException - if an IOException occurs in RasterImageLayer.getRasterData or in RasterImageIO.writeImage
      • saveImage

        public static void saveImage​(File file,
                                     String format,
                                     BufferedImage bufferedimage,
                                     org.locationtech.jts.geom.Envelope envelope)
                              throws IOException
        Export selected raster to various image file formats using ImageIO
        Parameters:
        file - destination file (absolute or relative path)
        format - Image I/O built-in support for both Oracle Java and OpenJDK is "gif", "png" and "tif". Oracle Java support also "jpg". Other formats might be work depending on installed codecs
        bufferedimage - BufferedImage
        envelope - Envelope
        Throws:
        IOException - if an IOException occurs
      • saveTIF_ImageIO

        public static void saveTIF_ImageIO​(File file,
                                           org.locationtech.jts.geom.Envelope envelope,
                                           javax.media.jai.PlanarImage planarimage)
                                    throws IOException
        Export selected raster to TIF/TFW - using ImageIO.class
        Parameters:
        file - file to save es D:/Openjump/test.tif
        envelope - envelope of selected Image Layer (RasterImageLayer.class)
        planarimage - PlanarImage of selected Image Layer (RasterImageLayer.class)
        Throws:
        IOException - if an IOException occurs
      • saveASC

        public static void saveASC​(File outfile,
                                   PlugInContext context,
                                   RasterImageLayer rLayer)
                            throws IOException
        Export selected monoband raster to ArcView Gridded Ascii (ASC)
        Parameters:
        outfile - file to save es D:/Openjump/test.asc
        context - Plugin Context
        rLayer - Selected Raster Image Layer (RasterImageLayer.class)
        Throws:
        IOException - if an IOException occurs
      • saveASC

        public static void saveASC​(File file,
                                   PlugInContext context,
                                   RasterImageLayer rLayer,
                                   int band)
                            throws IOException
        Export selected raster to ArcView Gridded Ascii (ASC)
        Parameters:
        file - file to save es D:/Openjump/test.asc
        context - Plugin Context
        rLayer - Selected Raster Image Layer (RasterImageLayer.class)
        band - Number of band to save (O=red, 1=green, 2=blue)
        Throws:
        IOException - if an IOException occurs
      • saveHDR

        public static void saveHDR​(File outFile,
                                   PlugInContext context,
                                   RasterImageLayer rLayer)
                            throws IOException
        Export selected raster to ArcView Gridded Binary header (HDR)
        Parameters:
        outFile - file to save es D:/Openjump/test.hdr
        context - . Plugin Context
        rLayer - . Selected Raster Image Layer (RasterImageLayer.class)
        Throws:
        IOException - if an IOException occurs
      • saveFLT

        public static void saveFLT​(File outfile,
                                   PlugInContext context,
                                   RasterImageLayer rLayer)
                            throws IOException
        Export selected monoband raster to ArcView Gridded Binary data (FLT)
        Parameters:
        outfile - file to save es D:/Openjump/test.flt
        context - Plugin Context
        rLayer - Selected Raster Image Layer (RasterImageLayer.class)
        Throws:
        IOException - if an IOException occurs
      • saveFLT

        public static void saveFLT​(File outFile,
                                   PlugInContext context,
                                   RasterImageLayer rLayer,
                                   int band)
                            throws IOException
        Export selected raster to ArcView Gridded Binary data (FLT)
        Parameters:
        outFile - file to save es D:/Openjump/test.flt
        context - Plugin Context
        rLayer - Selected Raster Image Layer (RasterImageLayer.class)
        band - Number of the band to save (O=1st band (red), 1=2nd band (green), 2=3rd band (blue), etc)
        Throws:
        IOException - if an IOException occurs
      • saveSurferGRD

        public static void saveSurferGRD​(File outfile,
                                         PlugInContext context,
                                         RasterImageLayer rLayer)
                                  throws IOException
        Export selected monoband raster to Surfer ASCII Grid (GRD)
        Parameters:
        outfile - file to save es D:/Openjump/test.grd
        context - Plugin Context
        rLayer - Selected Raster Image Layer (RasterImageLayer.class)
        Throws:
        IOException - if an IOException occurs
      • saveSurferGRD

        public static void saveSurferGRD​(File outfile,
                                         PlugInContext context,
                                         RasterImageLayer rLayer,
                                         int band)
                                  throws IOException
        Export selected raster to Surfer ASCII Grid (GRD)
        Parameters:
        outfile - file to save es D:/Openjump/test.grd
        context - . Plugin Context
        rLayer - . Selected Raster Image Layer (RasterImageLayer.class)
        band - . Number of band to save (O=1st band (red), 1=2nd band (green), 2=3rd band (blue), etc)
        Throws:
        IOException - if an IOException occurs
      • saveXYZ

        public static void saveXYZ​(File outfile,
                                   PlugInContext context,
                                   RasterImageLayer rLayer)
                            throws IOException
        Export selected raster to XYZ table. If the file is a multi banded raster each band is extracted to a proper band named "band1", "band2", etc
        Parameters:
        outfile - file to save es D:/Openjump/test.xyz
        context - . Plugin Context
        rLayer - . Selected Raster Image Layer (RasterImageLayer.class)
        Throws:
        IOException - if an IOException occurs
      • saveGrass

        public static void saveGrass​(File file,
                                     PlugInContext context,
                                     RasterImageLayer rLayer,
                                     int band)
                              throws IOException
        Test. Export selected raster to GRASS file.
        Parameters:
        file - file to save es D:/Openjump/test
        context - . Plugin Context
        rLayer - . Selected Raster Image Layer (RasterImageLayer.class)
        Throws:
        IOException - if an IOException occurs
      • loadTIF

        public static void loadTIF​(File file,
                                   PlugInContext context,
                                   String category)
                            throws Exception
        Load TIF file into OpenJUMP workbench
        Parameters:
        file - file to load es D:/Openjump/test.tif
        context - Plugin Context
        category - Name of the category to load the file
        Throws:
        NoninvertibleTransformException - , TiffReadingException, Exception
        Exception
      • loadASC

        public static void loadASC​(File file,
                                   PlugInContext context,
                                   String category)
                            throws Exception
        Load ArcView Gridded Ascii (ASC) file into OpenJUMP workbench
        Parameters:
        file - file to load
        context - the PlugInContext
        category - name of the category to load the file
        Throws:
        Exception - if an Exception occurs
      • saveFLT_mask

        public static void saveFLT_mask​(File outFile,
                                        PlugInContext context,
                                        RasterImageLayer rLayer,
                                        int band,
                                        float mindata,
                                        float maxdata,
                                        float nodata)
                                 throws IOException
        Mask a selected range of values of a raster. The range will be defined by a lower and upper values of the range. The values within the range will be substituted by nodata value. The output file is a Arcview Gridded Binary file (HDR/FLT)
        Parameters:
        outFile - file to save es D:/Openjump/test.flt
        context - Plugin Context
        rLayer - Selected Raster Image Layer (RasterImageLayer.class)
        band - band Number of the band to save (O=1st band (red), 1=2nd band (green), 2=3rd band (blue), etc)
        mindata - lower value of the mask range
        maxdata - upper value of the mask range
        nodata - nodata value
        Throws:
        IOException
      • saveFLT_extract

        public static void saveFLT_extract​(File outFile,
                                           PlugInContext context,
                                           RasterImageLayer rLayer,
                                           int band,
                                           float mindata,
                                           float maxdata,
                                           float nodata)
                                    throws IOException
        Extract a selected range of values of a raster. The range will be defined by a lower and upper values of the range. All the raster cell values outside this range of values will be substituted by nodata value.The output file is a Arcview Gridded Binary file (HDR/FLT)
        Parameters:
        outFile - file to save es D:/Openjump/test.flt
        context - Plugin Context
        rLayer - Selected Raster Image Layer (RasterImageLayer.class)
        band - band Number of the band to save (O=1st band (red), 1=2nd band (green), 2=3rd band (blue), etc)
        mindata - lower value of the extract range
        maxdata - upper value of the e range
        nodata - nodata value
        Throws:
        IOException