Package org.opengis.coverage.grid

Examples of org.opengis.coverage.grid.GridCoverageWriter


    public static void writeGridCoverageFromGrassraster( File mapFile, JGrassRegion writeRegion, GridCoverage2D grassCoverage )
            throws Exception {
        JGrassMapEnvironment mapEnvironment = new JGrassMapEnvironment(mapFile);
        GrassCoverageFormat format = new GrassCoverageFormatFactory().createFormat();
        GridCoverageWriter writer = format.getWriter(mapEnvironment.getCELL(), null);

        GeneralParameterValue[] readParams = null;
        if (writeRegion == null) {
            writeRegion = mapEnvironment.getActiveRegion();
        }
        readParams = JGrassCatalogUtilities.createGridGeometryGeneralParameter(writeRegion.getCols(), writeRegion.getRows(),
                writeRegion.getNorth(), writeRegion.getSouth(), writeRegion.getEast(), writeRegion.getWest(),
                mapEnvironment.getCoordinateReferenceSystem());

        writer.write(grassCoverage, readParams);
    }
View Full Code Here


                                    geodata = geodata.view(ViewType.GEOPHYSICS);

                                    File mapsetFile = oldMapEnvironment.getMAPSET();
                                    JGrassMapEnvironment newMapEnvironment = new JGrassMapEnvironment(mapsetFile, newMapName);
                                    format = new GrassCoverageFormatFactory().createFormat();
                                    GridCoverageWriter writer = format.getWriter(newMapEnvironment.getCELL(), null);
                                    writer.write(geodata, null);

                                    JGrassCatalogUtilities.addMapToCatalog(mapsetFile.getParent(), mapsetFile.getName(),
                                            newMapName, JGrassConstants.GRASSBINARYRASTERMAP);

                                }
View Full Code Here

                                    String mapName = mapFile.getName();
                                    mapName = FilenameUtils.getBaseName(mapName);
                                    JGrassMapEnvironment mapEnvironment = new JGrassMapEnvironment(mapsetFile, mapName);
                                    GrassCoverageFormat format = new GrassCoverageFormatFactory().createFormat();
                                    GridCoverageWriter writer = format.getWriter(mapEnvironment.getCELL(), null);

                                    GeneralParameterValue[] readParams = null;
                                    writer.write(geodata, readParams);

                                    JGrassCatalogUtilities.addMapToCatalog(mapsetFile.getParent(), mapsetFile.getName(), mapName,
                                            JGrassConstants.GRASSBINARYRASTERMAP);
                                    pm.worked(1);
                                }
View Full Code Here

        // creating a zip outputstream
        final ZipOutputStream outZ = new ZipOutputStream(output);
        output = outZ;

        // creating a writer
        final GridCoverageWriter writer = new GTopo30Writer(outZ);

        // writing
        if (writer != null) {
            writer.write(sourceCoverage, null);
        } else {
            throw new ServiceException("Could not create a writer for the format Gtopo30!");
        }

        // freeing everything
        writer.dispose();
        this.sourceCoverage.dispose(false);
        this.sourceCoverage = null;
    }
View Full Code Here

            gzipOut = new GZIPOutputStream(output);
            output = gzipOut;
        }

        try {
            final GridCoverageWriter writer = new ArcGridWriter(output);
            final ParameterValueGroup params = writer.getFormat().getWriteParameters();
            //params.parameter("Compressed").setValue(compressOutput);
            writer.write(sourceCoverage, null);

            if (gzipOut != null) {
                gzipOut.finish();
                gzipOut.flush();
            }

            // freeing everything
            writer.dispose();
            this.sourceCoverage.dispose(false);
            this.sourceCoverage = null;
        } catch (Exception e) {
            throw new WcsException(new StringBuffer("Problems Rendering Image").append(
                    e.getMessage()).toString(), e);
View Full Code Here

        final ParameterValueGroup writerParams = format.getWriteParameters();
        writerParams.parameter(AbstractGridFormat.GEOTOOLS_WRITE_PARAMS.getName().toString())
                    .setValue(wp);

        GridCoverageWriter writer = format.getWriter(output);
        writer.write(sourceCoverage,
            (GeneralParameterValue[]) writerParams.values().toArray(new GeneralParameterValue[1]));

        writer.dispose();

        this.sourceCoverage.dispose(false);
        this.sourceCoverage = null;
    }
View Full Code Here

    public void encode(OutputStream output) throws ServiceException, IOException {
        if (sourceCoverage == null) {
            throw new IllegalStateException("It seems prepare() has not been called or has not succeed");
        }

        final GridCoverageWriter writer = new WorldImageWriter(output);

        // writing parameters for Image
        final Format writerParams = writer.getFormat();
        final ParameterValueGroup writeParameters = writerParams.getWriteParameters();
        final ParameterValue format = writeParameters.parameter("Format");
        format.setValue(this.outputFormat.toLowerCase());

        // writing
        writer.write(sourceCoverage, new GeneralParameterValue[] {format});

        // freeing everything
        output.flush();
        writer.dispose();
        this.sourceCoverage.dispose(false);
        this.sourceCoverage = null;
    }
View Full Code Here

    // WRITING AND TESTING
    //
    //
    // /////////////////////////////////////////////////////////////////////
    final File writeFile = new File(new StringBuilder(writedir.getAbsolutePath()).append(File.separatorChar).append(cropped.getName().toString()).append(".tiff").toString());
    final GridCoverageWriter writer = format.getWriter(writeFile);
   
    try{
      writer.write(cropped, null);
    }catch (IOException e) {
    }
    finally{
      try{
        writer.dispose();
      }catch (Throwable e) {
      }
    }
    try{
      reader = new GeoTiffReader(writeFile, null);
View Full Code Here

        //
        //
        // /////////////////////////////////////////////////////////////////////
        final File writeFile = new File(writedir.getAbsolutePath() + File.separatorChar
                + cropped.getName().toString() + ".tiff");
        final GridCoverageWriter writer = format.getWriter(writeFile);
        // /////////////////////////////////////////////////////////////////////
        //
        // Create the writing params
        //
        // /////////////////////////////////////////////////////////////////////
        try {
            writer.write(cropped, null);
        } catch (IOException e) {
        } finally {
            try {
                writer.dispose();
            } catch (Throwable e) {
            }
        }
       
        // release things
View Full Code Here

      File testDir = TestData.file(this, "");
      newDir = new File(testDir.getAbsolutePath() + "/newDir");
      newDir.mkdir();

      // writing it down
      GridCoverageWriter writer = format.getWriter(newDir);
      writer.write(gc, null);

      /**
       *
       * STEP 2 Reading back into memory the previos coverage.
       *
 
View Full Code Here

TOP

Related Classes of org.opengis.coverage.grid.GridCoverageWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.