Tom Howe a écrit :
I need to take a grid coverage and clip it based on a Polygon. My
plan was to just loop through the cells of the coverage and check to
see if polygon.contains(point) from the cell. If so,, then add the
value to a new coverage. I was thinking about constraining this
further by only checking the cells in that are contained in the
bounding box of the polygon. Any thoughts on if this is the best way
to approach the problem or any suggestions on how to do this? I can
brute force it, but I wanted to see if anyone had better suggestions.
If the polygon is actually a rectangle, the "resample" operation whould
be quite efficient (it should maps to a JAI's "Crop" operation):
GridRange newRange = new GeneralGridRange(...);
GridGeometry newGeometry = new GridGeometry2D(newRange,
(MathTransform)null);
Coverage newCoverage = Operations.resample(source, null, newGeometry, null);
For more complex geometry, we don't have yet any explict API in
Geotools. But the most efficient way may be to use the JAI operations.
I'm not sure which JAI operation is the most appropriate, since I have
not yet investigated this problem. Maybe the "AndConst" operation with
some javax.media.jai.ROIShape inferred from yours Geometry. If an
appropriate JAI operation is found, we can get the RenderedImage using
GridCoverage2D.getRenderedImage(), apply the JAI operation and recreate
the GridCoverage2D with the operation result.
Actually I don't really have an easy way to suggest right now...
Martin.
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users