Package org.geotools.coverage.grid

Examples of org.geotools.coverage.grid.GridCoverageFactory


            LOGGER.warning("GDAL utilities are not in the path, skipping the test");
            return;
        }

        BufferedImage image = ImageIO.read(new File("./src/test/resources/rotated-image.png"));
        GridCoverage2D coverage = new GridCoverageFactory().create(
                "test",
                image,
                new ReferencedEnvelope(0, image.getWidth(), 0, image.getHeight(), CRS
                        .decode("EPSG:404000")));
        String gcps = "[" + //
View Full Code Here


     */
    protected static GridCoverage2D createTestCoverage(final int width, final int height,
                    final double envX0, final double envY0,
                    final double envWidth, final double envHeight) {

        final GridCoverageFactory factory = CoverageFactoryFinder.getGridCoverageFactory(null);

        WritableRaster raster =
                RasterFactory.createBandedRaster(DataBuffer.TYPE_FLOAT, width, height, 1, null);
        for (int y = 0; y < height; y++) {
            for (int x = 0; x < width; x++) {
                if( x<50 && y<50 ) { // upper left square: vertical lines
                    if(x % 5 == 0)
                        raster.setSample(x, y, 0, 0);
                    else
                        raster.setSample(x, y, 0, width);
                }
                else if(x < 50 && y > height-50) { // lower left square: horizontal lines
                    if(y % 5 == 0)
                        raster.setSample(x, y, 0, 0);
                    else
                        raster.setSample(x, y, 0, width);
                }
                else if(x > width- 50 && y < 50) { // upper right square: descending diagonal lines
                    if( (x-y) % 5 == 0)
                        raster.setSample(x, y, 0, 0);
                    else
                        raster.setSample(x, y, 0, width);
                }
                else if(x > width- 50 && y > height-50) { // lower right square: ascending diagonal lines
                    if( (x+y) % 5 == 0)
                        raster.setSample(x, y, 0, 0);
                    else
                        raster.setSample(x, y, 0, width);
                }
                else if(x % 50 == 0 || y % 50 == 0 || (x - y) % 100 == 0)
                    raster.setSample(x, y, 0, 0); // bigger lines
                else
                    raster.setSample(x, y, 0, x+y); // normal background
            }
        }
        final Color[] colors = new Color[]{
            Color.BLUE, Color.CYAN, Color.WHITE, Color.YELLOW, Color.RED
        };

        return factory.create("Float coverage", raster,
                new Envelope2D(DefaultGeographicCRS.WGS84, envX0, envY0, envWidth, envHeight),
                null, null,
                null, new Color[][]{colors}, null);
    }
View Full Code Here

                null, null,
                null, new Color[][]{colors}, null);
    }

    private static void view(RenderedImage ri, GridGeometry2D gg, GridSampleDimension[] gsd) {
        final GridCoverageFactory factory = CoverageFactoryFinder.getGridCoverageFactory(null);

        GridCoverage2D rendered = factory.create("Merged coverage", ri,
                gg, gsd, null, null);

        rendered.view(ViewType.RENDERED).show();
    }
View Full Code Here

TOP

Related Classes of org.geotools.coverage.grid.GridCoverageFactory

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.