|
From: Martin D. <mar...@ge...> - 2008-08-21 12:34:07
|
Michael Bedward a écrit : > How do I query a GridCoverage2D object to determine the width of its > cells in map units ? There is no method doing explicitly that. However you can query MathTransform2D gridToCRS = GridCoverage2D.getGridGeometry().getGridToCRS2D(); cast "gridToCRS" to java.awt.geom.AffineTransform (to be strict, you should check if it is really an instance of AffineTransform - it will be in most cases, but doesn't have to be in all cases). Once you have your "gridToCRS", you can query getScaleX() and getScaleY(). If there is no rotation, they will match the pixel width and height respectively. To be slightly more generic, you may invoke org.geotools.referencing.operation.matrix.XAffineTransform.getScaleX0(gridToCRS) and XAffineTransform.getScaleY0(gridToCRS) instead. They will work even if there is a rotation. Martin |