Package org.geotools.coverage.processing

Examples of org.geotools.coverage.processing.CoverageProcessor$LogLevel


    }

    private static GridCoverage2D projectTo(final GridCoverage2D coverage,
        final CoordinateReferenceSystem targetCRS, final GridGeometry2D geometry,
        final Hints hints, final boolean useGeophysics) {
        final CoverageProcessor processor = (hints != null) ? CoverageProcessor.getInstance(hints)
                                                            : CoverageProcessor.getInstance();
        final String arg1;
        final Object value1;
        final String arg2;
        final Object value2;

        if (targetCRS != null) {
            arg1 = "CoordinateReferenceSystem";
            value1 = targetCRS;

            if (geometry != null) {
                arg2 = "GridGeometry";
                value2 = geometry;
            } else {
                arg2 = "InterpolationType";
                value2 = "bilinear";
            }
        } else {
            arg1 = "GridGeometry";
            value1 = geometry;
            arg2 = "InterpolationType";
            value2 = "bilinear";
        }

        GridCoverage2D projected = coverage.geophysics(useGeophysics);
        final ParameterValueGroup param = processor.getOperation("Resample").getParameters();
        param.parameter("Source").setValue(projected);
        param.parameter(arg1).setValue(value1);
        param.parameter(arg2).setValue(value2);

        projected = (GridCoverage2D) processor.doOperation(param);

        final RenderedImage image = projected.getRenderedImage();
        projected = projected.geophysics(false);

        String operation = null;
View Full Code Here


                    final BoundingBox bbox = feature.getBounds();

                    /*
                     * crop on region of interest
                     */
                    final CoverageProcessor processor = CoverageProcessor.getInstance();
                    final ParameterValueGroup param = processor.getOperation("CoverageCrop")
                            .getParameters();
                    param.parameter("Source").setValue(gridCoverage2D);
                    param.parameter("Envelope").setValue(new GeneralEnvelope(bbox));
                    final GridCoverage2D cropped = (GridCoverage2D) processor.doOperation(param);

                    ROI roi = null;
                    final int numGeometries = geometry.getNumGeometries();
                    for (int i = 0; i < numGeometries; i++) {
                        Geometry geometryN = geometry.getGeometryN(i);
View Full Code Here

        GridCoverage2D coverage = GridCoverageTestBase.EXAMPLES.get(Integer.parseInt(args[0]));
        if (geophysics != null) {
            coverage = coverage.view(geophysics.booleanValue() ? ViewType.GEOPHYSICS : ViewType.RENDERED);
        }
        if (operation != null) {
            final CoverageProcessor processor = CoverageProcessor.getInstance();
            final ParameterValueGroup param = processor.getOperation(operation).getParameters();
            param.parameter("Source").setValue(coverage);
            coverage = (GridCoverage2D) processor.doOperation(param);
        }
        Viewer viewer = new Viewer(coverage);
        viewer.setLocale(locale);
        viewer = show(viewer, coverage.getName().toString(locale));
        if (palette) {
View Full Code Here

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

    final int uppers[] = range.getHigh().getCoordinateValues();
    uppers[0] ++;
    uppers[1] ++;
    final double newRange[] = new double[] { uppers[0] / newCols,uppers[1] / newRows };
    final CoverageProcessor processor = CoverageProcessor.getInstance();
    for (int i = 0; i < newRows; i++)
      for (int j = 0; j < newCols; j++) {

        // //
        //
        // computing the bbox for this tile
        //
        // //
        _maxx = minx + (j + 1) * tileGeoWidth;
        _minx = minx + (j) * tileGeoWidth;
        _maxy = miny + (i + 1) * tileGeoHeight;
        _miny = miny + (i) * tileGeoHeight;
        if (_maxx > maxx)
          _maxx = maxx;
        if (_maxy > maxy)
          _maxy = maxy;

        // //
        //
        // creating the output file
        //
        // //
        final File fileOut = new File(outputLocation, new StringBuilder(
            "mosaic").append("_").append(
            Integer.toString(i * newCols + j)).append(".").append(
            "tiff").toString());
        if (fileOut.exists())
          fileOut.delete();

        message = new StringBuilder("Preparing tile (col,row)==(")
            .append(j)
            .append(",")
            .append(i)
            .append(") to file ")
            .append(fileOut);
        if (LOGGER.isLoggable(Level.FINE))
          LOGGER.fine(message.toString());
        fireEvent(message.toString(), (j + i * newCols)/ totalNumberOfFile);

        // //
        //
        // building gridgeometry for the read operation
        //
        // //
        final ParameterValue<GridGeometry2D> gg =  ImageMosaicFormat.READ_GRIDGEOMETRY2D.createValue();
        final GeneralEnvelope cropEnvelope = new GeneralEnvelope(new double[] { _minx, _miny }, new double[] { _maxx,_maxy });
        cropEnvelope.setCoordinateReferenceSystem(inReader.getCrs());
        //we need to supply the requeste grid range but we use a fake one since we are using the ignore overviews switch
        gg.setValue(new GridGeometry2D(new GridEnvelope2D(new Rectangle(0, 0, 800, 800)), cropEnvelope));
        message = new StringBuilder("Reading with grid envelope ").append(cropEnvelope.toString());
        if (LOGGER.isLoggable(Level.FINE))
          LOGGER.fine(message.toString());
        fireEvent(message.toString(), (j + i * newCols)
            / totalNumberOfFile);

        // //
        //
        // read the needed part and then crop to be sure that we have what we need
        //
        // //
        GridCoverage2D gc;
        try {
          gc = (GridCoverage2D) inReader
              .read(new GeneralParameterValue[] { gg });


        } catch (IOException e) {
          LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e);
          fireEvent(e.getLocalizedMessage(), 0);
          return;
        }

        ParameterValueGroup param = processor.getOperation("CoverageCrop").getParameters();
        param.parameter("Source").setValue(gc);
        param.parameter("Envelope").setValue(cropEnvelope);
        param.parameter("ConserveEnvelope").setValue(Boolean.TRUE);
        final GridCoverage2D cropped = (GridCoverage2D) processor.doOperation(param);

        // //
        //
        // Adjusting the resolution in order to be the same as for all the others coverage
        //
        // //
        final GridEnvelope2D newGridrange = new GridEnvelope2D(new Rectangle2D.Double(0.0, 0.0, newRange[0],newRange[1]).getBounds());
        final GridGeometry2D scaledGridGeometry = new GridGeometry2D(newGridrange, cropEnvelope);
        param = processor.getOperation("Resample").getParameters();
        param.parameter("Source").setValue(cropped);
        param.parameter("CoordinateReferenceSystem").setValue(inReader.getCrs());
        param.parameter("GridGeometry").setValue(scaledGridGeometry);
        param.parameter("InterpolationType").setValue(Interpolation.getInstance(Interpolation.INTERP_NEAREST));
        gc = (GridCoverage2D) processor.doOperation(param);


        message = new StringBuilder("Scaling...");
        if (LOGGER.isLoggable(Level.FINE))
          LOGGER.fine(message.toString());
        fireEvent(message.toString(), 0);

        if (scaleAlgorithm.equalsIgnoreCase("nn")) {
          param = processor.getOperation("Scale").getParameters();
          param.parameter("Source").setValue(gc);
          param.parameter("xScale").setValue(new Float(1.0 / scaleFactor));
          param.parameter("yScale").setValue(new Float(1.0 / scaleFactor));
          param.parameter("xTrans").setValue(new Float(0));
          param.parameter("yTrans").setValue(new Float(0));
          param.parameter("Interpolation").setValue(Interpolation.getInstance(Interpolation.INTERP_BILINEAR));
          gc = (GridCoverage2D) CoverageToolsConstants.SCALE_FACTORY.doOperation(param, new Hints());
        } else if (scaleAlgorithm.equalsIgnoreCase("filt")) {
          // scaling
          param =  CoverageToolsConstants.FILTERED_SUBSAMPLE_FACTORY.getParameters();
          param.parameter("source").setValue(gc);
          param.parameter("scaleX").setValue(new Integer((int) scaleFactor));
          param.parameter("scaleY").setValue(new Integer((int) scaleFactor));
          param.parameter("qsFilterArray").setValue(new float[] { 0.5F, 1.0F / 3.0F, 0.0F,-1.0F / 12.0F });
          param.parameter("Interpolation").setValue(new InterpolationNearest());
          gc = (GridCoverage2D) CoverageToolsConstants.FILTERED_SUBSAMPLE_FACTORY.doOperation(param, new Hints());
        } else if (scaleAlgorithm.equalsIgnoreCase("bil")) {
          param = processor.getOperation("Scale").getParameters();
          param.parameter("Source").setValue(gc);
          param.parameter("xScale").setValue(
              new Float(1.0 / scaleFactor));
          param.parameter("yScale").setValue(
              new Float(1.0 / scaleFactor));
          param.parameter("xTrans").setValue(new Float(0));
          param.parameter("yTrans").setValue(new Float(0));
          param.parameter("Interpolation").setValue(Interpolation.getInstance(Interpolation.INTERP_BILINEAR));
          gc = (GridCoverage2D) CoverageToolsConstants.SCALE_FACTORY.doOperation(param, new Hints());
        } else if (scaleAlgorithm.equalsIgnoreCase("avg")) {
          param = processor.getOperation("SubsampleAverage").getParameters();
          param.parameter("Source").setValue(gc);
          param.parameter("scaleX").setValue(new Double(1.0 / scaleFactor));
          param.parameter("scaleY").setValue(new Double(1.0 / scaleFactor));
          param.parameter("Interpolation").setValue(scaleFactor);
          gc = (GridCoverage2D) CoverageToolsConstants.SUBSAMPLE_AVERAGE_FACTORY.doOperation(param, new Hints());
View Full Code Here

  private void mergePoly(
      final GridCoverage originalCoverage,
      final Polygon poly,
      final Resolution resolution ) {
    final CoverageProcessor processor = CoverageProcessor.getInstance();
    final AbstractOperation op = (AbstractOperation) processor.getOperation("Histogram");
    final ParameterValueGroup params = op.getParameters();
    params.parameter(
        "Source").setValue(
        originalCoverage);
    params.parameter(
View Full Code Here

        if(CRS.equalsIgnoreMetadata(coverage.getCoordinateReferenceSystem2D(), targetCRS)){
            return coverage;
        }

        // reproject
        final CoverageProcessor processor=hints==null?CoverageProcessor.getInstance():CoverageProcessor.getInstance(hints);
        final Operation operation = processor.getOperation("Resample");
        final ParameterValueGroup parameters = operation.getParameters();
        parameters.parameter("Source").setValue(coverage);
        parameters.parameter("CoordinateReferenceSystem").setValue(targetCRS);
        parameters.parameter("GridGeometry").setValue(null);
        parameters.parameter("InterpolationType").setValue(spatialInterpolation);
        return (GridCoverage2D) processor.doOperation(parameters);
    }
View Full Code Here

TOP

Related Classes of org.geotools.coverage.processing.CoverageProcessor$LogLevel

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.