Hi good people,

 

I'm trying to resample AND reproject a coverage and I'm having trouble
getting both operations to work together, although they work just fine
individually. Here's some code to show the problem:

 

      // get input file (a NAD27 greyscale coverage)

      final GeoTiffReader reader = new GeoTiffReader(new File(

                "d:\\A\\utm.tif"));

      final GridCoverage2D source= (GridCoverage2D) reader.read(null);

 

      source.show();

        

      /* create grid geometry from extent */

      int[] xx = {0, 0};

      int[] yy = {512, 512};

            

      GeneralGridRange range = new GeneralGridRange(xx, yy);

            

      Envelope2D envelope = source.getEnvelope2D();

 

// just downsample a quarter of the image

      Rectangle2D en = envelope.getBounds2D();

      en.setRect(en.getMinX(), en.getMinY(), en.getWidth()/2.0,
en.getHeight()/2.0);

      envelope.setRect(en);

            

      final Resample resampleFactory = new Resample();

            

      final GridGeometry2D gridGeometry =

      new GridGeometry2D(range, envelope);

      

// if I leave both reprojection and resampling, I get an all-zero picture

 

      DefaultProcessor processor = new DefaultProcessor(null);

      ParameterValueGroup resampleParams =
processor.getOperation("Resample").getParameters();

      resampleParams.parameter("Source").setValue(source);

 
//resampleParams.parameter("CoordinateReferenceSystem").setValue(DefaultGeog
raphicCRS.WGS84);

      resampleParams.parameter("GridGeometry").setValue(gridGeometry);

 

      final GridCoverage2D destination =
(GridCoverage2D)resampleFactory.doOperation(

                  resampleParams, 

                  null);

 

// downsampled raster looks ok

 

      destination.show();

 

// try to get the reprojected one as a second step, into a different
coverage, does not make

// a difference:

 

      ParameterValueGroup esampleParams =
processor.getOperation("Resample").getParameters();

      esampleParams.parameter("Source").setValue(destination);

 
resampleParams.parameter("CoordinateReferenceSystem").setValue(DefaultGeogra
phicCRS.WGS84);

 

      final GridCoverage2D odestination =
(GridCoverage2D)resampleFactory.doOperation(

                  resampleParams, 

                  null);

 

// this is all zero

 

      odestination.show();

 

 

Basically no matter how I do that, either operation works OK, but both
create a zeroed out coverage, with no errors or exceptions. Am I missing
something obvious?

 

Thanks for any advice,

ferdinando

 

 

 

---

Ferdinando Villa, Ph.D.

Associate Research Professor, Ecoinformatics Collaboratory, Gund Institute
for Ecological Economics, UVM

 <http://ecoinformatics.uvm.edu> http://ecoinformatics.uvm.edu

 

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to