Hello list,

Some time ago I raised a question about reading Tiff files that don't
conform with GeoTiff standard (such the data published by the EEA:
http://dataservice.eea.europa.eu/dataservice/).

Probably I'm going to explain something obvious for most GeoTools
users (because it is documented in Javadocs), but as it took a while
for me to find the solution, I want to complete this thread.
Simply adding some hints makes the trick:

File file = new File("C:\\test\\recorte_lceugr.tif");
GeoTiffFormat gtf = new GeoTiffFormat();
Hints hints = new Hints(Hints.DEFAULT_COORDINATE_REFERENCE_SYSTEM,
CRS.decode("EPSG:3035"));
GridCoverageReader reader = gtf.getReader(file, hints);

I hope it's useful for someone.

Best regards,

César


El día 7 de septiembre de 2009 12:46, César Martínez Izquierdo
<cesar....@gmail.com> escribió:
> El 7 de septiembre de 2009 11:27, Simone
> Giannecchini<simone.giannecch...@geo-solutions.it> escribió:
>> Ciao Cesar,
>> I am decently happy about the geotiff geotools plugin and therefore I
>> don't have any current plan for replacing it with the gdal one.
>> Nevertheless I have been thinking about including the geotiff gdal
>> plugin as well as an optional step in geotools, since it is currently
>> disabled. Daniele, what do you think? What would happen with the
>> GeoTools factory mechanism when we introduce two plugins for the same
>> format?
>>
>> About a brief, up-to-date description about raster current status in
>> GeoTools, and future plans, I will leave that for another email since
>> I am quite busy as of now :-).
>
> Hi Simone,
>
> I consider your first paragraph as the brief, up-to-date description I
> was expecting (at least, regarding GeoTiff).
> Thank you very much :-)
>
> Regarding the problem with these files, I think I found the cause. It
> seems a gdal effect (or defect) [1], which causes that some 'weird'
> coordinate systems don't get correctly stored in the Geotiff.
>
> I've exported the same area in EPSG:23030 (using arcgis), and the
> resulting file could be correctly loaded in GeoTools (and I could see
> the GeoTiff tags by using [fwtools] tiffinfo). However, it seems that
> EPSG:3035 is considered by GDAL as an uncommon CRS (despite it is the
> preferred projected CRS for the European Environmental Agency, for
> European-scale data).
>
> However, this doesn't help me, as I can't change Esri code... So it
> could be great if we could enable this support in GeoTools...
>
>
> Best regards,
>
>  César
>
>
> [1] See "Georeferencing" chapter: http://gdal.org/frmt_gtiff.html
>
>
>
>>
>> Ciao,
>> Simone.
>> -------------------------------------------------------
>> Ing. Simone Giannecchini
>> GeoSolutions S.A.S.
>> Founder - Software Engineer
>> Via Carignoni 51
>> 55041  Camaiore (LU)
>> Italy
>>
>> phone: +39 0584983027
>> fax:      +39 0584983027
>> mob:    +39 333 8128928
>>
>>
>> http://www.geo-solutions.it
>> http://geo-solutions.blogspot.com/
>> http://simboss.blogspot.com/
>> http://www.linkedin.com/in/simonegiannecchini
>>
>> -------------------------------------------------------
>>
>>
>>
>> 2009/9/7 César Martínez Izquierdo <cesar....@gmail.com>:
>>> Hi Simone,
>>>
>>> thank you for the interest.
>>> I will talk with the raster team at gvSIG to see what can be done to
>>> improve compatibility. I think format interoperability is very
>>> important. As far as I know, gvSIG uses gdal to generate these files.
>>>
>>> In the arcgis side, I guess we can't repair anything on their side,
>>> but we'd be very interested in geotools being able of reading them. I
>>> think arcgis also uses gdal to read/write them.
>>>
>>> I'd like to know if GeoTools plans to maintain GeoTiff standalone
>>> reader/writer, or if they plan to move it to the ImageIO-Ext GDAL
>>> framework. (A brief, up-to-date description about raster current
>>> status in GeoTools, and future plans would be great).
>>>
>>> Regards,
>>>
>>>  César
>>>
>>> El 4 de septiembre de 2009 19:32, Simone
>>> Giannecchini<simone.giannecch...@geo-solutions.it> escribió:
>>>> Ciao Cesar,
>>>> I quickly inspected those files and:
>>>>
>>>> 1> the gvsig one, is not a real geotiff, but rather a plain tiff with
>>>> a non-standard metadata file (the rmf file) which seems to be specific
>>>> to gvsig. I have never seen this one anyway
>>>> 2> the arcgis one is not a real geotiff again, but it contains a
>>>> proprietary xml file for th metadata. We don't actually read such a
>>>> format, although gdal seems to read it.
>>>>
>>>> Ciao,
>>>> Simone.
>>>> -------------------------------------------------------
>>>> Ing. Simone Giannecchini
>>>> GeoSolutions S.A.S.
>>>> Founder - Software Engineer
>>>> Via Carignoni 51
>>>> 55041  Camaiore (LU)
>>>> Italy
>>>>
>>>> phone: +39 0584983027
>>>> fax:      +39 0584983027
>>>> mob:    +39 333 8128928
>>>>
>>>>
>>>> http://www.geo-solutions.it
>>>> http://geo-solutions.blogspot.com/
>>>> http://simboss.blogspot.com/
>>>> http://www.linkedin.com/in/simonegiannecchini
>>>>
>>>> -------------------------------------------------------
>>>>
>>>>
>>>>
>>>> 2009/9/3 Simone Giannecchini <simone.giannecch...@geo-solutions.it>:
>>>>> Ciao Cesar,
>>>>> best thing would be if you could provide some sample data to me.
>>>>> Which version of geotools are you using?
>>>>>
>>>>> Simone.
>>>>>
>>>>> -------------------------------------------------------
>>>>> Ing. Simone Giannecchini
>>>>> GeoSolutions S.A.S.
>>>>> Founder - Software Engineer
>>>>> Via Carignoni 51
>>>>> 55041  Camaiore (LU)
>>>>> Italy
>>>>>
>>>>> phone: +39 0584983027
>>>>> fax:      +39 0584983027
>>>>> mob:    +39 333 8128928
>>>>>
>>>>>
>>>>> http://www.geo-solutions.it
>>>>> http://geo-solutions.blogspot.com/
>>>>> http://simboss.blogspot.com/
>>>>> http://www.linkedin.com/in/simonegiannecchini
>>>>>
>>>>> -------------------------------------------------------
>>>>>
>>>>>
>>>>>
>>>>> 2009/9/3 César Martínez Izquierdo <cesar....@gmail.com>:
>>>>>> Hello,
>>>>>>
>>>>>> I'm trying to read some (Geo)Tiff files with GeoTools, but I get an
>>>>>> error. My code is simple:
>>>>>>
>>>>>>
>>>>>> File file = new File("C:\\test\\recorte_lceugr.tif");
>>>>>> GeoTiffFormat gtf = new GeoTiffFormat();
>>>>>> GridCoverageReader reader = gtf.getReader(file);
>>>>>>
>>>>>>
>>>>>> But I get an exception in the third line.
>>>>>> If the TIFF was generated with gvSIG, I get the following exception:
>>>>>>
>>>>>> java.lang.IllegalArgumentException: GeoKey directory does not exist
>>>>>>        at 
>>>>>> org.geotools.gce.geotiff.IIOMetadataAdpaters.GeoTiffIIOMetadataDecoder.<init>(GeoTiffIIOMetadataDecoder.java:124)
>>>>>>        at 
>>>>>> org.geotools.gce.geotiff.GeoTiffReader.getHRInfo(GeoTiffReader.java:278)
>>>>>>        at 
>>>>>> org.geotools.gce.geotiff.GeoTiffReader.<init>(GeoTiffReader.java:222)
>>>>>>        at 
>>>>>> org.geotools.gce.geotiff.GeoTiffFormat.getReader(GeoTiffFormat.java:253)
>>>>>>        at 
>>>>>> org.geotools.gce.geotiff.GeoTiffFormat.getReader(GeoTiffFormat.java:213)
>>>>>>        at etclusi.tests.gt.TestGeoTiff.main(TestGeoTiff.java:24)
>>>>>>
>>>>>> If the TIFF was generated with ArcGIS, then I get:
>>>>>> 03-sep-2009 16:51:16
>>>>>> org.geotools.gce.geotiff.crs_adapters.GeoTiffMetadata2CRSAdapter
>>>>>> getGeoKeyAsInt
>>>>>> ADVERTENCIA: null
>>>>>> java.lang.NumberFormatException: null
>>>>>>        at java.lang.Integer.parseInt(Integer.java:415)
>>>>>>        at java.lang.Integer.parseInt(Integer.java:497)
>>>>>>        at 
>>>>>> org.geotools.gce.geotiff.crs_adapters.GeoTiffMetadata2CRSAdapter.getGeoKeyAsInt(GeoTiffMetadata2CRSAdapter.java:452)
>>>>>>        at 
>>>>>> org.geotools.gce.geotiff.crs_adapters.GeoTiffMetadata2CRSAdapter.createCoordinateSystem(GeoTiffMetadata2CRSAdapter.java:235)
>>>>>>        at 
>>>>>> org.geotools.gce.geotiff.GeoTiffReader.getHRInfo(GeoTiffReader.java:294)
>>>>>>        at 
>>>>>> org.geotools.gce.geotiff.GeoTiffReader.<init>(GeoTiffReader.java:222)
>>>>>>        at 
>>>>>> org.geotools.gce.geotiff.GeoTiffFormat.getReader(GeoTiffFormat.java:253)
>>>>>>        at 
>>>>>> org.geotools.gce.geotiff.GeoTiffFormat.getReader(GeoTiffFormat.java:213)
>>>>>>        at etclusi.tests.gt.TestGeoTiff.main(TestGeoTiff.java:24)
>>>>>> Exception in thread "main" java.lang.UnsupportedOperationException:
>>>>>> GeoTiffMetadata2CRSAdapter::createCoordinateSystem:Only Geographic &
>>>>>> Projected Systems are supported.
>>>>>>        at 
>>>>>> org.geotools.gce.geotiff.crs_adapters.GeoTiffMetadata2CRSAdapter.createCoordinateSystem(GeoTiffMetadata2CRSAdapter.java:243)
>>>>>>        at 
>>>>>> org.geotools.gce.geotiff.GeoTiffReader.getHRInfo(GeoTiffReader.java:294)
>>>>>>        at 
>>>>>> org.geotools.gce.geotiff.GeoTiffReader.<init>(GeoTiffReader.java:222)
>>>>>>        at 
>>>>>> org.geotools.gce.geotiff.GeoTiffFormat.getReader(GeoTiffFormat.java:253)
>>>>>>        at 
>>>>>> org.geotools.gce.geotiff.GeoTiffFormat.getReader(GeoTiffFormat.java:213)
>>>>>>        at etclusi.tests.gt.TestGeoTiff.main(TestGeoTiff.java:24)
>>>>>>
>>>>>> In this second case (ArcGIS), the problem might be that they are not
>>>>>> real GeoTiff files, as pointed by Niels Hoffmann in [1]. I'm not an
>>>>>> expert on the topic, so I can't be sure.
>>>>>>
>>>>>> Anyway, I am able to read these TIFFs with uDig 1.1.1, so I guess that
>>>>>> GeoTools is able to read them, and then the problem should be in my
>>>>>> code or my runtime configuration.
>>>>>>
>>>>>> Any idea?
>>>>>>
>>>>>>
>>>>>> Best Regards,
>>>>>>
>>>>>>
>>>>>>
>>>>>> [1] 
>>>>>> http://52north.org/pipermail/geoprocessingservices/2009-July/000445.html
>>>>>>
>>>>>>
>>>>>> --
>>>>>> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>>>>>>   César Martínez Izquierdo
>>>>>>   GIS developer
>>>>>>   -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
>>>>>>   ETC-LUSI: http://etc-lusi.eionet.europa.eu/
>>>>>>   Universitat Autònoma de Barcelona (SPAIN)
>>>>>> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>>>>>>
>>>>>> ------------------------------------------------------------------------------
>>>>>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 
>>>>>> 30-Day
>>>>>> trial. Simplify your report design, integration and deployment - and 
>>>>>> focus on
>>>>>> what you do best, core application coding. Discover what's new with
>>>>>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>>>>>> _______________________________________________
>>>>>> Geotools-gt2-users mailing list
>>>>>> Geotools-gt2-users@lists.sourceforge.net
>>>>>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>>>>>>
>>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>>>   César Martínez Izquierdo
>>>   GIS developer
>>>   -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
>>>   ETC-LUSI: http://etc-lusi.eionet.europa.eu/
>>>   Universitat Autònoma de Barcelona (SPAIN)
>>> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>>>
>>> ------------------------------------------------------------------------------
>>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
>>> trial. Simplify your report design, integration and deployment - and focus 
>>> on
>>> what you do best, core application coding. Discover what's new with
>>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>>> _______________________________________________
>>> Geotools-gt2-users mailing list
>>> Geotools-gt2-users@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>>>
>>
>
>
>
> --
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>   César Martínez Izquierdo
>   GIS developer
>   -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
>   ETC-LUSI: http://etc-lusi.eionet.europa.eu/
>   Universitat Autònoma de Barcelona (SPAIN)
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>



-- 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   César Martínez Izquierdo
   GIS developer
   -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
   ETC-LUSI: http://etc-lusi.eionet.europa.eu/
   Universitat Autònoma de Barcelona (SPAIN)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Geotools-gt2-users mailing list
Geotools-gt2-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to