[geotk] Reading and displaying tif file in geotoolkit

Westgård Trond trondwe at IMR.no
Fri Jan 6 04:51:10 EST 2012


Hi Johann,
And thank you for a quick answer (and a happy new year ;-) ).

It is right, I use the Oasis-dialog to choose the filetype (and consequently to find the correct imagereader).
For JPEG, BMP PNG, GIF I get two entries in the list of possible readers (example: GIF-WF and GIF), that must mean that the GIF-WF reader take for granted that there exists a "world file".

But in the case of TIFF there comes only one alternative (the TIFF-WF alternative is missing in the list).

The list is build by a call to: 
        
        final IIORegistry registry = IIORegistry.getDefaultInstance();
        final Iterator<? extends ImageReaderWriterSpi> it = registry.getServiceProviders(ImageReaderSpi.class, true);

Then this iterator is "looped" to get a set of file-filters that maps to the correct service.

Is there a missing reference to a .jar file in the pom.xml file ???

A related question that Martin said he would test - read a "native" ESRI grid dataset. Such a set is stored in:

ftp://ftp.imr.no/nmd/geomatys/

Here is an example of a tiff-file with world and .prj file. But equally important an example where depth data is stored in the .dbf file, it is important for us to access such datasets to find out the depth at different locations and areas.
Is there a reader for such a dataset ?

Best Regards

Trond


-----Original Message-----
From: geotoolkit-bounces at lists.osgeo.org [mailto:geotoolkit-bounces at lists.osgeo.org] On Behalf Of sorel johann
Sent: 6. januar 2012 09:18
To: Westgård Trond; geotoolkit at lists.osgeo.org
Subject: Re: [geotk] Reading and displaying tif file in geotoolkit

Hello trond,

I guess you are using the widget in the oasis project.
When you select the file, you must choose the correct Tiff reader in the file format combo box.
there should be 3 differents readers available that handle tiff files.

- Standard Java tiff reader - TIFF (*.tif, *.tiff)
- WorldImage reader - TIFF-WF (*.tif, *.tiff)
- GeoTiff reader - geotiff (*.tif, *.tiff)

since you have the : Com.sun.media.imageioimpl.plugin.tiff.TIFFImageReader
I think you selected the standard java reader, which doesn't read the projection informations in the tfw and prj which explains the transformation issue you had. You should select the World Image reader.

I hope this helps.

johann


On 03/01/2012 09:55, Westgård Trond wrote:
> Hello Martin,
> And a happy new year to you too ;)
>
> What I use is not the classes directly, Johann has made calls to different file types in the "MapHandler" we have in our project.
>
> Both .jpg and .tif ends up in a call to the same static method (factory) in the geotk-coverage-3.x-SNAPSHOT library:
>
> In the "MapHandler" the class org.geotoolkit.coverage.io.CoverageIO is used like this:
>
>      public MapLayer createLayer(final File imageFile) {
>          try {
>              final String name = imageFile.getName();
>              final GridCoverageReader reader = CoverageIO.createSimpleReader(imageFile);
>              final MutableStyle style = new RandomStyleBuilder().createRasterStyle();
>              final CoverageMapLayer layer = MapBuilder.createCoverageLayer(reader, style, name);
>              layer.setDescription(SF.description(name, "")); // BREAK POINT HERE
>              layer.setName(name);
>              return layer;
>          } catch (CoverageStoreException ex) {
>              LOGGER.log(Level.WARNING, ex.getMessage(),ex);
>          }
>          return null;
>      }
>
> The service found for the .tif file (debugs CoverageMapLayer's reader) is:
>
> Com.sun.media.imageioimpl.plugin.tiff.TIFFImageReader
>
> I suspect that this is a reader for geoTiff files because when I go to the source:
>
> http://www.java2s.com/Open-Source/Java-Document/6.0-JDK-Modules/Java-A
> dvanced-Imaging/com/sun/media/imageioimpl/plugins/tiff/TIFFImageReader
> .java.htm
>
> it looks to me that this reader looks for the information that is stored in a .tfw file is looked up within the .tif file itself.
> And where is the .prj file used ?
> So maybe it should be a check that if a .tfw file exists another ImageReader should be used ?
>
> But what I really want is a coverageReader that takes for instance the format that ESRI ArcMap use, then I get the extra information on the depth of each pixel for GEBCO depth data. I want to use this to find the depth at any point for example for a Oceanographic station. Then I need a reader that also goes into the attribute data stored in the .dbf file. An example of such a dataset you will find at:
>
> ftp://ftp.imr.no/nmd/geomatys/
>
> Here is the .tif, .tfw and .prj files in the example stored as well.
>
> Best Regards
>
> Trond
>
>
>
> -----Original Message-----
> From: geotoolkit-bounces at lists.osgeo.org 
> [mailto:geotoolkit-bounces at lists.osgeo.org] On Behalf Of Martin 
> Desruisseaux
> Sent: 2. januar 2012 16:52
> To: geotoolkit at lists.osgeo.org
> Subject: Re: [geotk] Reading and displaying tif file in geotoolkit
>
> Hello Trond
>
> I'm not sure if this is the cause, but there is a particular issue with the TIFF format to consider. Experience suggests that on some platforms, new codecs appear magically after an AWT window has been created, especially the "Standard TIFF image reader". This is independant of Geotk. For graphical applications, we recommend to invoke the following methods, in that order, after the Window has been created but before it is made visible (It is okay to invoke those methods more than once):
>
> org.geotoolkit.image.jai. setDefaultCodecPreferences(); 
> org.geotoolkit.image.io.plugin.WorldFileImageReader.Spi.registerDefaul
> ts(ServiceRegistry);
>
> The idea is to make sure that the "Standard TIFF image reader" is registered before to invoke the above initialization methods. Does it help?
>
>> A related questions: Does geotoolkit read the native ESRI-grid format 
>> (where we have the info catalog storing the attribute values) ?
>>
> Johann is in better position for this question...
>
>       Regards,
>
>           Martin
>
> _______________________________________________
> Geotoolkit mailing list
> Geotoolkit at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/geotoolkit
>

_______________________________________________
Geotoolkit mailing list
Geotoolkit at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/geotoolkit


More information about the Geotoolkit mailing list