I get geoTiff metadata with GeoTiffIIOMetadataAdapter class:
String filename = pathToMyTiffFile;
FileImageInputStream f = new FileImageInputStream(
new RandomAccessFile(filename, "r"));
// Look through ImageIO readers
Iterator iter = ImageIO.getImageReaders(f);
IIOMetadata imdata = null;
GeoTiffIIOMetadataAdapter geo_data;
while (iter.hasNext() && imdata == null) {
ImageReader reader = (ImageReader) iter.next();
reader.setInput(f, true);
String reader_name = reader.getFormatName().toLowerCase();
if (reader_name.equalsIgnoreCase("tif")) {
// Get Image metadata
imdata = reader.getImageMetadata(0);
geo_data = new GeoTiffIIOMetadataAdapter(imdata);
if (geo_data != null &&
geo_data.getGeoKeyDirectoryVersion() == 1) {
geo_data.getModelTiePoints(); //here i get [0.0,0.0,0.0,173084.9999999999,5845515.0,0.0]
}
}
}
How can I extract/convert this array to the usual latitude/longitude coordinates? Am I right that 173084.9999999999,5845515.0 is the coordinates of upper-left point of the tiff file?
Thanks in advance!
The answer is: yes, it is left-upper point of my tiff file. My Tiff is in http://spatialreference.org/ref/epsg/32612/.
To convert coordinates to wsg84( http://spatialreference.org/ref/epsg/4326/ ) with geotools I needed: