Issue Type: Bug Bug
Affects Versions: 2.7.3
Assignee: Simone Giannecchini
Attachments: ImageTest_CropCoverage.zip
Components: coverage
Created: 09/Oct/13 3:56 PM
Description:

I am attempting to crop a raster by specifying a geobounds (ReferencedEnvelope) and a shapefile. My approach is to use the CoverageCrop processor using the ROI parameter. The ROI parameter is a GeometryCollection consisting of all the features in the shapefile (which are Polygons and MultiPolygons).

For broad bounds it seems to work. However, with narrow bounds, I see two modes of failure that I've traced down to Crop.java:

A. uncropped coverage.

pbj.add(MosaicDescriptor.MOSAIC_TYPE_OVERLAY);
pbj.add(null);
pbj.add(roiarr);
pbj.add(null);
pbj.add(CoverageUtilities.getBackgroundValues(sourceCoverage));

//prepare the final layout
final Rectangle bounds = rasterSpaceROI.getBounds2D().getBounds();
Rectangle.intersect(bounds, sourceGridRange, bounds);
if(bounds.isEmpty())
throw new CannotCropException(Errors.format(ErrorKeys.CANT_CROP));

// we do not have to crop in this case (should not really happen at
// this time)
if (bounds.getBounds().equals(sourceGridRange) && isSimpleTransform)
return sourceCoverage; /// Note that this is a silent failure.

B. IllegalArgumentException: Dimension are too large (??)

//conserve the input grid to world transformation
return new GridCoverageFactory(hints).create(
sourceCoverage.getName(),
croppedImage,
new GridGeometry2D(
new GridEnvelope2D(croppedImage.getBounds()), // getBounds fails. croppedImage.bounds has height == width == 0.0
sourceGridGeometry.getGridToCRS2D(PixelOrientation.CENTER),
sourceCoverage.getCoordinateReferenceSystem()
),
(GridSampleDimension[]) (actionTaken == 1 ?null :sourceCoverage.getSampleDimensions().clone()),
new GridCoverage[]

{ sourceCoverage }

,
rasterSpaceROI != null ?Collections.singletonMap("GC_ROI", rasterSpaceROI) :null

);

I am attaching a repro case that uses GT v10.0: See tutorial/org.geotools.msr.ImageTest.java:
// NG: returns uncropped coverage: ReferencedEnvelope bounds = new ReferencedEnvelope(-124.5, -122.25, 46.8, 48.5, DefaultGeographicCRS.WGS84);
// NG: Dimensions too large: ReferencedEnvelope bounds = new ReferencedEnvelope(-124.8, -122.25, 46.8, 48.5, DefaultGeographicCRS.WGS84);
// OK for smaller version of the shapefile with only USA feature,
// BUT NG for full dataset result in Dimensions too large: ReferencedEnvelope bounds = new ReferencedEnvelope(-125, -122.25, 46.8, 48.5, DefaultGeographicCRS.WGS84);
// OK
ReferencedEnvelope bounds = new ReferencedEnvelope(-130, -122.25, 46.8, 48.5, DefaultGeographicCRS.WGS84);

I've also reproduced with GT 2.7.3

Environment: Windows 7 / Java 1.6
Project: GeoTools
Priority: Major Major
Reporter: michael rosen
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk
_______________________________________________
GeoTools-Devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to