Examples of GridCoverageReader


Examples of org.opengis.coverage.grid.GridCoverageReader

   */
  public void writeGrassUnCompressed(File rf, File wf) throws Exception {

            final Hints hints = new Hints(Hints.DEFAULT_COORDINATE_REFERENCE_SYSTEM,DefaultGeographicCRS.WGS84);
    /** Step 1: Reading the coverage */
    GridCoverageReader reader = new ArcGridReader(rf,hints);
    final GridCoverage2D gc1 = (GridCoverage2D) reader.read(null);
    assertTrue(CoverageUtilities.hasRenderingCategories(gc1));

    /** Step 2: Write grid coverage out to temp file */
    final GridCoverageWriter writer = new ArcGridWriter(wf);

    // setting write parameters
    ParameterValueGroup params;
    params = writer.getFormat().getWriteParameters();
    params.parameter("GRASS").setValue(true);
    final ArcGridWriteParams wp = new ArcGridWriteParams();
    wp.setSourceBands(new int[] { 0 });
    params.parameter(
        AbstractGridFormat.GEOTOOLS_WRITE_PARAMS.getName().toString())
        .setValue(wp);
    // params.parameter("compressed").setValue(false);
    GeneralParameterValue[] gpv = {
        params.parameter("GRASS"),
        params.parameter(AbstractGridFormat.GEOTOOLS_WRITE_PARAMS
            .getName().toString()) };
    writer.write(gc1, gpv);
    writer.dispose();

    /** Step 3: Read the just written coverage */
    GridCoverageReader reader2 = new ArcGridReader(wf,hints);
    final GridCoverage2D gc2 = (GridCoverage2D) reader2.read(null);

    /** Step 4: Check if the 2 coverage are equals */
    compare(gc1, gc2);

    /** Step 5: Show the new coverage */
 
View Full Code Here

Examples of org.opengis.coverage.grid.GridCoverageReader

   */
  public void writeEsriUnCompressed(File rf, File wf) throws Exception {

            final Hints hints = new Hints(Hints.DEFAULT_COORDINATE_REFERENCE_SYSTEM,DefaultGeographicCRS.WGS84);
    /** Step 1: Reading the coverage */
    GridCoverageReader reader = new ArcGridReader(rf,hints);
    final GridCoverage2D gc1 = (GridCoverage2D) reader.read(null);
    assertTrue(CoverageUtilities.hasRenderingCategories(gc1));

    /** Step 2: Write grid coverage out to temp file */
    final GridCoverageWriter writer = new ArcGridWriter(wf);

    // setting write parameters
    ParameterValueGroup params;
    params = writer.getFormat().getWriteParameters();
    params.parameter("GRASS").setValue(false);
    final ArcGridWriteParams wp = new ArcGridWriteParams();
    wp.setSourceBands(new int[] { 0 });
    params.parameter(
        AbstractGridFormat.GEOTOOLS_WRITE_PARAMS.getName().toString())
        .setValue(wp);
    // params.parameter("compressed").setValue(false);
    GeneralParameterValue[] gpv = {
        params.parameter("GRASS"),
        params.parameter(AbstractGridFormat.GEOTOOLS_WRITE_PARAMS
            .getName().toString()) };
    writer.write(gc1, gpv);
    writer.dispose();

    /** Step 3: Read the just written coverage */
    GridCoverageReader reader2 = new ArcGridReader(wf,hints);
    final GridCoverage2D gc2 = (GridCoverage2D) reader2.read(null);

    /** Step 4: Check if the 2 coverage are equals */
    compare(gc1, gc2);

    /** Step 5: Show the new coverage */
 
View Full Code Here

Examples of org.opengis.coverage.grid.GridCoverageReader

      final Hints hints = new Hints(Hints.DEFAULT_COORDINATE_REFERENCE_SYSTEM,DefaultGeographicCRS.WGS84);
    LOGGER.info("Reading the coverage through a file");
    // get a gzipped ascii grid
    final File f = TestData.file(this, "arcgrid/spearfish.asc.gz");
    // Reading the coverage through a file
    GridCoverageReader reader = new ArcGridReader(f);
    final GridCoverage2D gc1 = (GridCoverage2D) reader.read(null);

    LOGGER.info("Reading the gzipped coverage through an ImageInputStream");
    // Reading the coverage through an ImageInputStream
    final ImageInputStream iiStream = ImageIO
        .createImageInputStream( new GZIPInputStream(
            new FileInputStream(f)));
    reader = new ArcGridReader(iiStream,hints);
    final GridCoverage2D gc2 = (GridCoverage2D) reader.read(null);

    LOGGER.info(" Reading the gzipped coverage through an InputStream");
    // Reading the coverage through an InputStream
    reader = new ArcGridReader( new GZIPInputStream(
        new FileInputStream(f)),hints);
    final GridCoverage2D gc3 = (GridCoverage2D) reader.read(null);
   
    LOGGER.info("Reading the gzipped coverage through a URL");
    // Reading the coverage through a URL
    reader = new ArcGridReader( f.toURI().toURL(),hints);
    final GridCoverage2D gc4 = (GridCoverage2D) reader.read(null);

    // show the coverage or try to load the data
    if (TestData.isInteractiveTest()) {
      gc1.show();
      gc2.show();
View Full Code Here

Examples of org.opengis.coverage.grid.GridCoverageReader

        geopkg.add(entry, cov, format);

        assertTableExists("world");
        assertRasterEntry(entry);

        GridCoverageReader r = geopkg.reader(entry, format);
        GridCoverage2D c = (GridCoverage2D) r.read(null);
        assertNotNull(c);
    }
View Full Code Here

Examples of org.opengis.coverage.grid.GridCoverageReader

        geopkg.add(entry, cov, format);
        assertTableExists("Pk50095");
        assertRasterEntry(entry);

        GridCoverageReader r = geopkg.reader(entry, format);
        GridCoverage2D c = (GridCoverage2D) r.read(null);
        assertNotNull(c);
    }
View Full Code Here

Examples of org.opengis.coverage.grid.GridCoverageReader

        // Selection of the File to use
        File tiff = TestData.file(AffineProcessTest.class, "sample.tif");
        // Reading of the file with the GeoTiff reader
        AbstractGridFormat format = GridFormatFinder.findFormat(tiff);
        // Get a reader for the selected format
        GridCoverageReader reader = format.getReader(tiff);
        // Read the input Coverage
        coverage = (GridCoverage2D) reader.read(null);
        // Reader disposal
        reader.dispose();

        // Definition of the interpolation type
        nearest = new InterpolationNearest();
        bilinear = new InterpolationBilinear();
        bicubic = new InterpolationBicubic(8);
View Full Code Here

Examples of org.opengis.coverage.grid.GridCoverageReader

        // Selection of the File to use
        File tiff = TestData.file(RasterAsPointCollectionProcessTest.class, "sample.tif");
        // Reading of the file with the GeoTiff reader
        AbstractGridFormat format = GridFormatFinder.findFormat(tiff);
        // Get a reader for the selected format
        GridCoverageReader reader = format.getReader(tiff);
        // Read the input Coverage
        inputCoverage = (GridCoverage2D) reader.read(null);
        // Reproject to the default WGS84 CRS
        final CoverageProcessor processor = CoverageProcessor.getInstance(GeoTools
                .getDefaultHints());
        final ParameterValueGroup param = processor.getOperation("Resample").getParameters();
        param.parameter("Source").setValue(inputCoverage);
        param.parameter("CoordinateReferenceSystem").setValue(DefaultGeographicCRS.WGS84);
        coverage = (GridCoverage2D) processor.doOperation(param);
        // Reader disposal
        reader.dispose();
        // Definition of the Image Size
        pixelNumber = coverage.getRenderedImage().getHeight()
                * coverage.getRenderedImage().getWidth();
        // Definition of the process
        process = new RasterAsPointCollectionProcess();
View Full Code Here

Examples of org.opengis.coverage.grid.GridCoverageReader

        Registry.setNativeAccelerationAllowed("Mosaic", false);
        // First file selection
        File input = TestData.file(BandProcessTest.class, "sample.tif");
        AbstractGridFormat format = GridFormatFinder.findFormat(input);
        // Get a reader for the selected format
        GridCoverageReader reader = format.getReader(input);
        // Read the input Coverage
        coverage1 = (GridCoverage2D) reader.read(null);
        // Reader disposal
        reader.dispose();

        // Second File selection
        coverage2 = coverage1;

        // Third file selection (This file is similar to the first one but it is translated by 1 on the X direction)
        File input2 = TestData.file(BandProcessTest.class, "sample2.tif");
        format = GridFormatFinder.findFormat(input2);
        // Get a reader for the selected format
        reader = format.getReader(input2);
        // Read the input Coverage
        coverage3 = (GridCoverage2D) reader.read(null);
        // Reader disposal
        reader.dispose();
    }
View Full Code Here

Examples of org.opengis.coverage.grid.GridCoverageReader

    @SuppressWarnings("deprecation")
    public GridCoverageReader getGridCoverageReader( CoverageStoreInfo info, Hints hints )
        throws IOException {
       
        final AbstractGridFormat gridFormat = info.getFormat();
        GridCoverageReader reader = null;
        Object key;
        if ( hints != null ) {
            // expand the hints if necessary
            final String formatName = gridFormat.getName();
            if (formatName.equalsIgnoreCase(IMAGE_MOSAIC) || formatName.equalsIgnoreCase(IMAGE_PYRAMID)){
View Full Code Here

Examples of org.opengis.coverage.grid.GridCoverageReader

     *
     * @throws IOException Any errors that occur loading the coverage.
     */
    @SuppressWarnings("deprecation")
    public GridCoverage getGridCoverage( CoverageInfo info, ReferencedEnvelope env, Hints hints) throws IOException {
        final GridCoverageReader reader = getGridCoverageReader(info.getStore(), hints);
        if(reader == null) {
            return null;
        }
       
        return getGridCoverage(info, reader, env, hints);
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.