Examples of GeoTiffFormat


Examples of org.geotools.gce.geotiff.GeoTiffFormat

    public synchronized AbstractGridCoverage2DReader getReader() {
        if (this.reader == null) {
            try {
                File file = new File(getIdentifier().toURI());
                GeoTiffFormat geoTiffFormat = (GeoTiffFormat) getFormat();
                this.reader = (AbstractGridCoverage2DReader) geoTiffFormat.getReader(file);
            } catch (Exception ex) {
                this.message = ex;
            }
        }
        return this.reader;
View Full Code Here

Examples of org.geotools.gce.geotiff.GeoTiffFormat

                coverage2D = (GridCoverage2D) Operations.DEFAULT.resample(coverage2D, newCrs);
            }
        }

        if (isTiff) {
            final GeoTiffFormat format = new GeoTiffFormat();
            final GeoTiffWriteParams wp = new GeoTiffWriteParams();
            // wp.setProgressiveMode(GeoTiffWriteParams.MODE_DEFAULT);
            wp.setCompressionMode(GeoTiffWriteParams.MODE_DEFAULT);
            wp.setTilingMode(GeoToolsWriteParams.MODE_DEFAULT);
            final ParameterValueGroup paramWrite = format.getWriteParameters();
            paramWrite.parameter(AbstractGridFormat.GEOTOOLS_WRITE_PARAMS.getName().toString()).setValue(wp);
            File dumpFile = new File(newFilePath + ".tif");
            GeoTiffWriter gtw = (GeoTiffWriter) format.getWriter(dumpFile);
            gtw.write(coverage2D, (GeneralParameterValue[]) paramWrite.values().toArray(new GeneralParameterValue[1]));
        }
        if (isAscii) {
            final ArcGridFormat format = new ArcGridFormat();
            final ArcGridWriteParams wp = new ArcGridWriteParams();
            // wp.setProgressiveMode(GeoTiffWriteParams.MODE_DEFAULT);
            // wp.setCompressionMode(GeoTiffWriteParams.MODE_DEFAULT);
            // wp.setTilingMode(GeoToolsWriteParams.MODE_DEFAULT);
            final ParameterValueGroup paramWrite = format.getWriteParameters();
            paramWrite.parameter(AbstractGridFormat.GEOTOOLS_WRITE_PARAMS.getName().toString()).setValue(wp);
            File dumpFile = new File(newFilePath + ".asc");
            ArcGridWriter gtw = (ArcGridWriter) format.getWriter(dumpFile);
            gtw.write(coverage2D, (GeneralParameterValue[]) paramWrite.values().toArray(new GeneralParameterValue[1]));
        }
    }
View Full Code Here

Examples of org.geotools.gce.geotiff.GeoTiffFormat

       
        GeoTiffServiceExtension fac = new GeoTiffServiceExtension();
        URL url = Data.getResource(GeoTiffServiceTest.class, TIFF_1);
       
        GeoTiffFormatFactorySpi factory = GeoTiffServiceExtension.getFactory();
        GeoTiffFormat format = (GeoTiffFormat) factory.createFormat();
       
        try {
            ID id = new ID(url);
            File file = id.toFile();
       
            format.accepts(file);
           
        } catch (RuntimeException ex) {
            ex.printStackTrace();
        }
       
View Full Code Here

Examples of org.geotools.gce.geotiff.GeoTiffFormat

        if (sourceCoverage == null) {
            throw new IllegalStateException("It seems prepare() has not been called"
                + " or has not succeed");
        }

        final GeoTiffFormat format = new GeoTiffFormat();
        final GeoTiffWriteParams wp = new GeoTiffWriteParams();
        wp.setCompressionMode(GeoTiffWriteParams.MODE_EXPLICIT);
        wp.setCompressionType("LZW");
        wp.setCompressionQuality(0.75F);
        wp.setTilingMode(GeoToolsWriteParams.MODE_EXPLICIT);
        wp.setTiling(256, 256);

        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();
View Full Code Here

Examples of org.geotools.gce.geotiff.GeoTiffFormat

                            } finally {
                                closer.close();
                            }
                        }

                        return new GeoTiffFormat().getReader(geotiffFile);
                    } catch (Throwable t) {
                        throw ExceptionUtils.getRuntimeException(t);
                    }

                }
View Full Code Here

Examples of org.geotools.gce.geotiff.GeoTiffFormat

                try {
                    long t0 = System.currentTimeMillis();
                    GeoTiffWriteParams wp = new GeoTiffWriteParams();
                    wp.setCompressionMode(GeoTiffWriteParams.MODE_EXPLICIT);
                    wp.setCompressionType("LZW");
                    ParameterValueGroup params = new GeoTiffFormat().getWriteParameters();
                    params.parameter(AbstractGridFormat.GEOTOOLS_WRITE_PARAMS.getName().toString()).setValue(wp);
                    new GeoTiffWriter(outStream).write(coverage, (GeneralParameterValue[]) params.values().toArray(new GeneralParameterValue[1]));
                    //new GeoTiffWriter(outStream).write(coverage, null); //wasn't this line writing twice and trashing compressed version?
                    long t1 = System.currentTimeMillis();
                    LOG.debug("wrote geotiff in {}msec", t1-t0);
View Full Code Here

Examples of org.geotools.gce.geotiff.GeoTiffFormat

        this.path = path;
    }

    @Override
    public GridCoverage2D getGridCoverage() {
        GeoTiffFormat format = new GeoTiffFormat();
        GeoTiffReader reader = null;

        try {
            if (path == null) {
                throw new RuntimeException("Path not set");
            }
            reader = format.getReader(path);
            coverage = reader.read(null);
        } catch (IOException e) {
            throw new RuntimeException("Error getting coverage automatically. ", e);
        }
View Full Code Here

Examples of org.geotools.gce.geotiff.GeoTiffFormat

        GridCoverage2D coverage = new GridCoverageFactory().create("OTPAnalyst", imagePixelData, refEnvelope);
        try {
            GeoTiffWriteParams wp = new GeoTiffWriteParams();
            wp.setCompressionMode(GeoTiffWriteParams.MODE_EXPLICIT);
            wp.setCompressionType("LZW");
            ParameterValueGroup params = new GeoTiffFormat().getWriteParameters();
            params.parameter(AbstractGridFormat.GEOTOOLS_WRITE_PARAMS.getName().toString()).setValue(wp);
            GeoTiffWriter writer = new GeoTiffWriter(new File(fileName));
            writer.write(coverage, (GeneralParameterValue[]) params.values().toArray(new GeneralParameterValue[1]));
        } catch (Exception e) {
            LOG.error("exception while writing geotiff.");
View Full Code Here

Examples of org.geotools.gce.geotiff.GeoTiffFormat

        ra.close();
    }

    @Test
    public void testCreateRasterEntry() throws Exception {
        GeoTiffFormat format = new GeoTiffFormat();
        GeoTiffReader reader = format.getReader(setUpGeoTiff());
        GridCoverage2D cov = reader.read(null);

        RasterEntry entry = new RasterEntry();
        entry.setTableName("world");
View Full Code Here

Examples of org.geotools.gce.geotiff.GeoTiffFormat

        wp.setCompressionMode(GeoTiffWriteParams.MODE_EXPLICIT);
        wp.setCompressionType("LZW");
        wp.setCompressionQuality(0.75F);
        wp.setTilingMode(GeoToolsWriteParams.MODE_EXPLICIT);
        wp.setTiling(128, 128);
        GeoTiffFormat format = new GeoTiffFormat();
        final ParameterValueGroup writerParams = format.getWriteParameters();
        writerParams.parameter(AbstractGridFormat.GEOTOOLS_WRITE_PARAMS.getName().toString())
                .setValue(wp);

        // write down
        GeoTiffWriter writer = (GeoTiffWriter) format.getWriter(outStream);
        try {
            GeneralParameterValue[] params = (GeneralParameterValue[]) writerParams.values()
                    .toArray(new GeneralParameterValue[1]);
            writer.write(coverage, params);
        } finally {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.