I have a geotiff file and I use geotools library for parsing it.
This is my code:
File f = new File("myFile.tif");
ParameterValue policy = AbstractGridFormat.OVERVIEW_POLICY.createValue();
policy.setValue(OverviewPolicy.IGNORE);
ParameterValue gridsize = AbstractGridFormat.SUGGESTED_TILE_SIZE.createValue();
ParameterValue useJaiRead = AbstractGridFormat.USE_JAI_IMAGEREAD.createValue();
useJaiRead.setValue(true);
GridCoverage2D image = new GeoTiffReader(f).read(new GeneralParameterValue[]{policy, gridsize, useJaiRead});
Rectangle2D bounds2D = image.getEnvelope2D().getBounds2D();
GridGeometry2D geometry = image.getGridGeometry();
System.out.println(geometry);
System.out.println(bounds2D);
The output of geometry is:
GridGeometry2D[
GeneralGridEnvelope[0..1199, 0..1399],
PARAM_MT[
"Affine",
PARAMETER["num_row", 3],
PARAMETER["num_col", 3],
PARAMETER["elt_0_0", 996.4799194335938],
PARAMETER["elt_0_2", -598386.1975402832],
PARAMETER["elt_1_1", -999.6777954101562],
PARAMETER["elt_1_2", 650290.4111022949]
]
]
The output of bounds2D is:
java.awt.geom.Rectangle2D$Double[x=-598884.4375, y=-748758.6635742188, w=1195775.9033203125, h=1399548.9135742188]
What does this information mean?
No comments:
Post a Comment