public static int [ ] getLoopColsRowsForSubregion ( GridCoverage2D gridCoverage , Envelope2D subregion ) throws Exception { GridGeometry2D gridGeometry = gridCoverage . getGridGeometry ( ) ; GridEnvelope2D subRegionGrid = gridGeometry . worldToGrid ( subregion ) ; int minCol = subRegionGrid . x ; int maxCol = subRegionGrid . x + subRegionGrid . width ; int minRow = subRegionGrid . y ; int maxRow = subRegionGrid . y + subRegionGrid . height ; return new int [ ] { minCol , maxCol , minRow , maxRow } ; }
Get the cols and rows ranges to use to loop the original gridcoverage .