Package org.geotools.coverage.grid

Examples of org.geotools.coverage.grid.GridCoverage2D.evaluate()


                SimpleFeature feature = iter.next();
                Coordinate coord = ((Geometry)feature.getDefaultGeometry()).getCoordinate();
                Point2D worldPos = new Point2D.Double(coord.x, coord.y);
                int value = (Integer) feature.getAttribute("value");
               
                cov.evaluate(worldPos, covValues);
                assertEquals(value, covValues[0]);
            }
        } finally {
            iter.close();
        }
View Full Code Here


            Coordinate[] coords = ((Geometry)feature.getDefaultGeometry()).getCoordinates();
            for (Coordinate coord : coords) {
                gridP.x = coord.x == gridDim.width ? (int)coord.x-1 : (int)coord.x;
                gridP.y = coord.y == gridDim.height ? (int)coord.y-1 : (int)coord.y;

                cov.evaluate(gridP, covValue);
                Float value = (Float)feature.getAttribute("value");
                assertEquals(value.floatValue(), covValue[0], .01);
            }
        }
    }
View Full Code Here

            Coordinate[] coords = ((Geometry)feature.getDefaultGeometry()).getCoordinates();
            for (Coordinate coord : coords) {
                gridP.x = coord.x == gridDim.width ? (int)coord.x-1 : (int)coord.x;
                gridP.y = coord.y == gridDim.height ? (int)coord.y-1 : (int)coord.y;

                cov.evaluate(gridP, covValue);
                int value = Integer.valueOf((String)feature.getAttribute("value"));
                assertEquals(covValue[0], value);
            }
        }
    }
View Full Code Here

      GridCoverageFactory gcf = new GridCoverageFactory();
      GridCoverage2D coverage = gcf.create("Intepolated Coverage",  interp.get2DGrid(), env);//.show();
     
     
      //Assert.assertEquals( Double.parseDouble((coverage.evaluate(a, (Set)(new HashSet())).iterator().next()).toString()), pointsAndValues.get(a).floatValue(), 0.01);
      Assert.assertEquals( coverage.evaluate(a, new float[1])[0], pointsAndValues.get(a).floatValue(), 0.01);
     
     
      // We can also get interpolated value at any DirectPosition
      float myValue = interp.getValue(a);
      Assert.assertEquals( interp.getValue(a), pointsAndValues.get(a).floatValue(), 0.0);       
View Full Code Here

    GridCoverage2D coverage = reader.read(null);
   
    // direct access
    DirectPosition position = new DirectPosition2D( crs, x, y);
   
    double[] sample = (double[]) coverage.evaluate( position ); // assume double
   
    // resample with the same array
    sample = coverage.evaluate( position, sample );
    // exampleGridCoverageDirect end
}
View Full Code Here

    DirectPosition position = new DirectPosition2D( crs, x, y);
   
    double[] sample = (double[]) coverage.evaluate( position ); // assume double
   
    // resample with the same array
    sample = coverage.evaluate( position, sample );
    // exampleGridCoverageDirect end
}

}
View Full Code Here

        final GridCoverageFactory factory = CoverageFactoryFinder.getGridCoverageFactory(null);
        GridCoverage2D coverage = factory.create("translated", ti, new Envelope2D(wgs84LatLon, 3, 5, 6, 8));
       
        // verify we're good
        int[] pixel = new int[3];
        coverage.evaluate((DirectPosition) new DirectPosition2D(4, 6), pixel);
        assertEquals(0, pixel[0]);
        assertEquals(255, pixel[1]);
        assertEquals(0, pixel[2]);
       
        // now reproject flipping the axis
View Full Code Here

        GridGeometry gg = new GridGeometry2D(new GridEnvelope2D(-10, -10, 5, 5), (Envelope) new Envelope2D(wgs84LonLat, 5, 3, 8, 6));
        GridCoverage2D flipped = (GridCoverage2D) Operations.DEFAULT.resample(coverage, wgs84LonLat, 
                gg, Interpolation.getInstance(Interpolation.INTERP_NEAREST));

        // before the fix the pixel would have been black
        flipped.evaluate((DirectPosition) new DirectPosition2D(6, 4), pixel);
        assertEquals(0, pixel[0]);
        assertEquals(255, pixel[1]);
        assertEquals(0, pixel[2]);
    }
View Full Code Here

        if (isValid()) {
            GridCoverage2D cov = covRef.get();
            ReferencedEnvelope env = new ReferencedEnvelope(cov.getEnvelope2D());
            DirectPosition2D trPos = getTransformed(pos);
            if (env.contains(trPos)) {
                Object objArray = cov.evaluate(trPos);
                Number[] bandValues = asNumberArray(objArray);
                if (bandValues != null) {
                    for( Number value : bandValues ) {
                        list.add(value);
                    }
View Full Code Here

        // Check that on the center of the image there are nodata
        DirectPosition point = new DirectPosition2D(mosaic.getCoordinateReferenceSystem(),
                actual.getCenterX(), actual.getCenterY());
        double nodata = CoverageUtilities.getBackgroundValues(coverage1)[0];
        double result = ((int[]) mosaic.evaluate(point))[0];
        Assert.assertEquals(nodata, result, TOLERANCE);

        // Check that on the Upper Left border pixel there is valid data
        point = new DirectPosition2D(mosaic.getCoordinateReferenceSystem(), actual.getMinX()
                + finalRes, actual.getMinY() + finalRes);
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.