Package org.geotools.gce.geotiff

Examples of org.geotools.gce.geotiff.GeoTiffReader


                geodata = arcGridReader.read(null);
                geodata = geodata.view(ViewType.GEOPHYSICS);
                geodata = JGrassCatalogUtilities.removeNovalues(geodata);
                fileCrs = arcGridReader.getCrs();
            } else if (mapFile.getName().endsWith(".tif") || mapFile.getName().endsWith(".tiff")) {
                GeoTiffReader geotiffGridReader = new GeoTiffReader(mapFile);
                geodata = geotiffGridReader.read(null);
                geodata = geodata.view(ViewType.GEOPHYSICS);
                geodata = JGrassCatalogUtilities.removeNovalues(geodata);
                fileCrs = geotiffGridReader.getCrs();
            }

            HashMap<String, Double> regionParams = JGrassCatalogUtilities.getRegionParamsFromGridCoverage(geodata);
            double n = regionParams.get(JGrassCatalogUtilities.NORTH);
            double s = regionParams.get(JGrassCatalogUtilities.SOUTH);
View Full Code Here


                                        geodata = geodata.view(ViewType.GEOPHYSICS);
                                        geodata = JGrassCatalogUtilities.removeNovalues(geodata);
                                        fileCrs = arcGridReader.getCrs();
                                    } else if (mapFile.getName().toLowerCase().endsWith(".tif")
                                            || mapFile.getName().toLowerCase().endsWith(".tiff")) {
                                        GeoTiffReader geotiffGridReader = new GeoTiffReader(mapFile);
                                        geodata = geotiffGridReader.read(null);
                                        geodata = geodata.view(ViewType.GEOPHYSICS);
                                        geodata = JGrassCatalogUtilities.removeNovalues(geodata);
                                        fileCrs = geotiffGridReader.getCrs();
                                    }

                                    // if required, reproject
                                    if (!CRS.equalsIgnoreMetadata(jGrassCrs, fileCrs)) {
                                        geodata = (GridCoverage2D) Operations.DEFAULT.resample(geodata, jGrassCrs);
View Full Code Here

        Multipart multipart = (Multipart) body.getContent();
        return multipart;
    }

    private GridCoverage2D readCoverage(InputStream is) throws Exception {
        GeoTiffReader reader = new GeoTiffReader(is);
        GridCoverage2D coverage = (GridCoverage2D) reader.read(null);
        reader.dispose();
        return coverage;
    }
View Full Code Here

     * @throws ActionException
     * @throws NumberFormatException
     */
    protected void checkRasterSize(File dataFile, UNREDDLayer layer) throws ActionException, NumberFormatException {
        //= check that raster size is the expected one
        GeoTiffReader reader;
        try {
            reader = new GeoTiffReader(dataFile);
        } catch (Exception e) {
            throw new ActionException(this, "Error reading tiff file " + dataFile, e);
        }

        GridEnvelope ge = reader.getOriginalGridRange();
//            GridCoverage2D gc2d = reader.read(null);
//            GridGeometry2D gg2d = gc2d.getGridGeometry();
//            GridEnvelope  ge = gg2d.getGridRange();
        try {
            int expectedW = Float.valueOf(layer.getAttribute(Attributes.RASTERPIXELWIDTH)).intValue();
            int expectedH = Float.valueOf(layer.getAttribute(Attributes.RASTERPIXELHEIGHT)).intValue();
            int foundW = ge.getSpan(0);
            int foundH = ge.getSpan(1);
            if ( expectedW != foundW || expectedH != foundH ) {
                throw new ActionException(this, "Bad raster size " + foundW + "x" + foundH + ", expected " + expectedW + "x" + expectedH);
            }

            //= check that extent is the expected one
//            checkCoord(layer, Attributes.RASTERX0)
            double expectedX0 = Double.valueOf(layer.getAttribute(Attributes.RASTERX0));
            double expectedX1 = Double.valueOf(layer.getAttribute(Attributes.RASTERX1));
            double expectedY0 = Double.valueOf(layer.getAttribute(Attributes.RASTERY0));
            double expectedY1 = Double.valueOf(layer.getAttribute(Attributes.RASTERY1));
            Envelope env = reader.getOriginalEnvelope();
//            Envelope env = gc2d.getEnvelope();
            double foundX0 = env.getMinimum(0);
            double foundX1 = env.getMaximum(0);
            double foundY0 = env.getMinimum(1);
            double foundY1 = env.getMaximum(1);
View Full Code Here

    }

    @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);
        }

        return coverage;
View Full Code Here

    @Before
    public void getData() throws IOException {
        MapProjection.SKIP_SANITY_CHECKS = true;
        File coverageFile = TestData.copy(this, "geotiff/world.tiff");
        assertTrue(coverageFile.exists());
        reader = new GeoTiffReader(coverageFile);
    }
View Full Code Here

    @Test
    public void testTransformReprojectedGridReader() throws Exception {
        Style style = RendererBaseTest.loadStyle(this, "coverageCenter.sld");

        GeoTiffReader reader = new GeoTiffReader(TestData.copy(this, "geotiff/world.tiff"));

        MapContent mc = new MapContent();
        mc.addLayer(new GridReaderLayer(reader, style));

        StreamingRenderer renderer = new StreamingRenderer();
View Full Code Here

    @Test
    public void testTransformReprojectedGridCoverage() throws Exception {
        Style style = RendererBaseTest.loadStyle(this, "coverageCenter.sld");

        GeoTiffReader reader = new GeoTiffReader(TestData.copy(this, "geotiff/world.tiff"));

        MapContent mc = new MapContent();
        mc.addLayer(new GridCoverageLayer(reader.read(null), style));

        StreamingRenderer renderer = new StreamingRenderer();
        renderer.setMapContent(mc);

        ReferencedEnvelope reWgs84 = new ReferencedEnvelope(-70, 70, -160, 160,
View Full Code Here

    @Before
    public void getData() throws IOException {
        MapProjection.SKIP_SANITY_CHECKS = true;
        File coverageFile = TestData.copy(this, "geotiff/world.tiff");
        assertTrue(coverageFile.exists());
        worldReader = new GeoTiffReader(coverageFile);

        // grab also the global precipitation
        File file = TestData.copy(this, "arcgrid/arcgrid.zip");
        assertTrue(file.exists());
View Full Code Here

      CoordinateReferenceSystem mapCRS = CRS.decode("EPSG:3857", true);
      ReferencedEnvelope read3857 = read26915.transform(mapCRS, true);
     
      // setup map content
      StyleBuilder sb = new StyleBuilder();
        Layer layer = new GridReaderLayer(new GeoTiffReader(testFile), sb.createStyle(sb.createRasterSymbolizer()));
        MapContent mc = new MapContent();
        mc.getViewport().setBounds(read3857);
        mc.addLayer(layer);
       
        StreamingRenderer sr = new StreamingRenderer();
View Full Code Here

TOP

Related Classes of org.geotools.gce.geotiff.GeoTiffReader

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.