我使用 GeoTiffIIOMetadataAdapter 类获取 geoTiff 元数据:
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]
}
}
}
如何将此数组提取/转换为通常的纬度/经度坐标?173084.9999999999,5845515.0 是 tiff 文件左上角的坐标,我说得对吗?
提前致谢!