I am using the java.awt.Rectangle
class to construct subsets of a GEOTIFF file. In order to do this I would need to specify the x,y offsets, height and width of each subset image. In my particular case I would need to crop the original GEOTIFF image bottom to top. The java.awt.Rectangle
class specifies that the origin point is to be found in the upper left hand corner.
Please let me know if the calculation of the image offsets are correct and/or there is a better way of calculating the image offsets. The crop(r
) method is a proprietary method used to crop subsets of the original image.
int width = 40;
int height = 34;
int cellSize = 3600;
int xOffset = 0;
int yOffset = 0;
int pixelWidth = cellSize * width;
int pixelHeight = cellSize * height;
for (int i = 0 ; i < width; i++)
{
for (int j = 0; j < height; j++)
{
yOffset = pixelHeight - cellSize *(j+1) ;
Rectangle r = new Rectangle(xOffset,
yOffset,
cellSize,
cellSize);
crop(r);
}
xOffset = pixelWidth - cellSize * (i+1);
}