Package org.geotools.coverage

Examples of org.geotools.coverage.GridSampleDimension


    // get a coverage
    GridCoverage2D gc = CoverageFactoryFinder.getGridCoverageFactory(null)
        .create(
            "name",
            JAI.create("ImageRead", TestData.file(this,"smalldem.tif")),
            envelope,new GridSampleDimension[]{new GridSampleDimension("dem")},null,null);
    SubchainStyleVisitorCoverageProcessingAdapter rsh = new RasterSymbolizerHelper(gc, null);
    final RasterSymbolizer rs = extractRasterSymbolizer(sld);
    rsh.visit(rs);
    testRasterSymbolizerHelper(rsh);
   
View Full Code Here


    java.net.URL surl = TestData.url(this, "landsat.sld");
    SLDParser stylereader = new SLDParser(sf, surl);
    StyledLayerDescriptor sld = stylereader.parseSLD();

    final GridSampleDimension[] gsd={
        new GridSampleDimension("test1BandByte_SLD1"),
        new GridSampleDimension("test1BandByte_SLD2"),
        new GridSampleDimension("test1BandByte_SLD3"),
        new GridSampleDimension("test1BandByte_SLD4"),
        new GridSampleDimension("test1BandByte_SLD5"),
        new GridSampleDimension("test1BandByte_SLD6"),
      new GridSampleDimension("test1BandByte_SLD")
    };
    // get a coverage
    GeneralEnvelope envelope = new GeneralEnvelope(new double[] { -180,-90 },new double[] { 180,90 });
          envelope.setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84);     
    final GridCoverage2D gc = CoverageFactoryFinder.getGridCoverageFactory(null)
View Full Code Here

                envelope.setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84);     
    GridCoverage2D gc = CoverageFactoryFinder.getGridCoverageFactory(null)
        .create(
            "name",
            JAI.create("ImageRead", TestData.file(this,"smalldem.tif")),
            envelope,new GridSampleDimension[]{new GridSampleDimension("dem")},null,null);
    SubchainStyleVisitorCoverageProcessingAdapter rsh = new RasterSymbolizerHelper(gc, null);
    final RasterSymbolizer rs = extractRasterSymbolizer(sld);
    rsh.visit(rs);
   
    //test
View Full Code Here

    // get a coverage
    GridCoverage2D gc = CoverageFactoryFinder.getGridCoverageFactory(null)
        .create(
            "name",
            JAI.create("ImageRead", TestData.file(this,"test_ushort.tif")),
            envelope,new GridSampleDimension[]{new GridSampleDimension("test_dimension")},null,null);
    SubchainStyleVisitorCoverageProcessingAdapter rsh = new RasterSymbolizerHelper(gc, null);
    final RasterSymbolizer rs = extractRasterSymbolizer(sld);
    rsh.visit(rs);
    // Check if the final image has been rescaled to bytes
    RenderedImage outputImage = ((GridCoverage2D)rsh.getOutput()).getRenderedImage();
View Full Code Here

            final ColorModel cm = asciiCoverage.getColorModel();
                  final ColorInterpretation colorInterpretation=TypeMap.getColorInterpretation(cm, 0);
                  if(colorInterpretation==null)
                         throw new IOException("Unrecognized sample dimension type");
                 
      final GridSampleDimension band = new GridSampleDimension(
          coverageName, new Category[] { nan }, uom).geophysics(true);
      final Map<String, Double> properties = new HashMap<String, Double>();
      properties.put("GC_NODATA", new Double(inNoData));

      //
View Full Code Here

                  source.getSampleDimensions(),
                  new GridCoverage[]{source},
                  props);
                } else {
          // replicate input bands
          final GridSampleDimension sd[]= new GridSampleDimension[numActualBands];
          for(int i=0;i<numActualBands;i++)
            sd[i]=(GridSampleDimension) source.getSampleDimension(0);
          output = factory.create(
                  "ce_coverage"+source.getName().toString(),
                  finalImage,
View Full Code Here

      // It is important to have such categories since we might have holes
      // in the categories we are going to build hence it is important to
      // have a valid NoDataValue that we can use.
      //
      // /////////////////////////////////////////////////////////////////////
      final GridSampleDimension candidateSD = (GridSampleDimension) sourceCoverage.getSampleDimension(0);
      double[] candidateNoDataValues = preparaNoDataValues(candidateSD);

      // /////////////////////////////////////////////////////////////////////
      //
      // Main Loop
View Full Code Here

          final int outputChannels=classified.getColorModel().getNumComponents();
                final int numBands=classified.getSampleModel().getNumBands();
                assert outputChannels==1||outputChannels==3||outputChannels==4;
                final GridSampleDimension [] sd= new GridSampleDimension[numBands];
                for(int i=0;i<numBands;i++)
            sd[i]= new GridSampleDimension(TypeMap.getColorInterpretation(classified.getColorModel(), i).name());
         
          ////
                //
                // Create the the output coverage by preserving its gridgeometry and its bands
                //
View Full Code Here

      if (layout != null)
        hints.add(new RenderingHints(JAI.KEY_IMAGE_LAYOUT, layout));
      op = FormatDescriptor.create(op, Integer.valueOf(op.getSampleModel().getDataType()), hints);
      final GridSampleDimension [] sd= new GridSampleDimension[op.getSampleModel().getNumBands()];
      for(int i=0;i<sd.length;i++)
          sd[i]= new GridSampleDimension(TypeMap.getColorInterpretation(op.getColorModel(), i).name());
                   
      return getCoverageFactory().create(
              "BandMerge",
              op,
              gridGeometry,
View Full Code Here

    ///////////////////////////////////////////////////////////////////////
    //let's check the number of bands
    final SampleModel outputImageSampleModel= outputImage.getSampleModel();
    int numBands=outputImageSampleModel.getNumBands();
    final int dataType= outputImageSampleModel.getDataType();
    GridSampleDimension sd[];
    if(numBands>4)
    {
      //get the visible band
      final int visibleBand=CoverageUtilities.getVisibleBand(outputImage);
      outputImage=
        new ImageWorker(outputImage).setRenderingHints(this.getHints()).retainBands(new int[]{visibleBand}).getRenderedImage();
      sd=new GridSampleDimension[]{(GridSampleDimension) output.getSampleDimension(visibleBand)};
    }else{
        sd=output.getSampleDimensions();
    }

    //more general case, let's check the data type and let go only USHORT and BYTE
    // TODO I am not sure this will work with multipacked types (using INT for an RGB as an instance)
    // TODO should we go to component color model also?
    // TODO use JAI TOOLS statistics and ignore no data properly.
    switch(dataType){
      // in case the original image has a USHORT pixel type without being associated
      // with an index color model I would still go to 8 bits
      case DataBuffer.TYPE_USHORT:
        if(outputImage.getColorModel() instanceof IndexColorModel){
          break;
        }
      case DataBuffer.TYPE_DOUBLE:
      case DataBuffer.TYPE_FLOAT:
      case DataBuffer.TYPE_INT:
      case DataBuffer.TYPE_SHORT:
      //rescale to byte
      outputImage=
        new ImageWorker(outputImage).setRenderingHints(this.getHints()).rescaleToBytes().getRenderedImage();
       
    }
   
          // ///////////////////////////////////////////////////////////////////
          // Apply opacity if needed
          // ///////////////////////////////////////////////////////////////////
          final RenderedImage finalImage;
          if(opacity < 1) {
              ImageWorker ow = new ImageWorker(outputImage);
              finalImage = ow.applyOpacity(opacity).getRenderedImage();
             
              numBands=finalImage.getSampleModel().getNumBands();
              sd= new GridSampleDimension[numBands];
              for(int i=0;i<numBands;i++) {
                  sd[i]= new GridSampleDimension(TypeMap.getColorInterpretation(finalImage.getColorModel(), i).name());
              }
             
                    // create a new grid coverage but preserve as much input as possible
                    return this.getCoverageFactory().create(
                            output.getName(),
View Full Code Here

TOP

Related Classes of org.geotools.coverage.GridSampleDimension

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.