pleae help me about geotiff

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

pleae help me about geotiff

zhang lihui
hi,

   i want to read geotiff in java, if i have a coordinate value(just like
latitude and longtitude),then i read the image data around the value, i
down the geotiff-jai.jar,but i have not doc about it ,and how to use
it,please help me,

_________________________________________________________________
与联机的朋友进行交流,请使用 MSN Messenger:  http://messenger.msn.com/cn 

_______________________________________________
Geotiff mailing list
[hidden email]
http://lists.maptools.org/mailman/listinfo/geotiff
Reply | Threaded
Open this post in threaded view
|

Re: pleae help me about geotiff

Pascal Quesseveur
>"zl" == zhang lihui <[hidden email]> writes:

  zl>    i want to read geotiff in java, if i have a coordinate value(just like
  zl> latitude and longtitude),then i read the image data around the value, i
  zl> down the geotiff-jai.jar,but i have not doc about it ,and how to use
  zl> it,please help me,

I am going to try to give you some explanations.

In standard Java images are read through the ImageIO API. JAI is an
extension designed to make some advanced image manipulations. That
extension contains a TIFF reader that knows about the GeoTIFF
tags. The TIFF reader can also be used with ImageIO as long as you have
installed the JAIImageIO plugin.

The TIFF reader reads the image file and exposes the TIFF tags as
metadata that can be retrieved and processed by an application. The
GeoTiffIIOMetadataAdapter is a convenience class to help manage
GeoTIFF metadata. From the GeoTiffIIOMetadataAdapter documentation:

 * This class provides an abstraction from the details of TIFF data
 * access for the purpose of retrieving GeoTIFF metadata from an image.

It does exactly what is written.

I have included some code that shows how to access GeoTIFF
metadata. Image file is read using ImageIO. The code looks through
ImageIO readers to identify the TIFF reader. There must be others
ways to read the image.

,----
|         FileImageInputStream f = new FileImageInputStream (
|             new RandomAccessFile (fname, "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)
|                 {
|                     int imw = geo_data.getImageWidth ();
|                     int imh = geo_data.getImageHeight ();
| ...
`----

HTH


--
Pascal Quesseveur, [hidden email]


_______________________________________________
Geotiff mailing list
[hidden email]
http://lists.maptools.org/mailman/listinfo/geotiff