That is the same library geotools uses. Just like we use JTS from geometry
we use ImageIO-EXT to read the spatial data formats.
--
Jody Garnett


On Thu, 9 Sept 2021 at 06:45, Juan Felipe Arjona <jfarj...@jfarjona.com>
wrote:

> Thanks Jody!
>
> Yes you are right, the uDig I am running uses GT v. 14.1.  I tried to
> downgrade my dependencies but I am using classes that were not present at
> that release, so difficult to test.
>
> On the other hand, I think that uDig has its own tiff reader, from their
> pom.xml:
>
> ...
>
> <groupId>it.geosolutions.imageio-ext</groupId>
> <artifactId>imageio-ext-tiff</artifactId>
> <version>1.1.13</version>
>
> ...
>
> See their website:
> https://github.com/geosolutions-it/imageio-ext/wiki/Available-Components
>
> My guess is that they are not using GeoTools Tiff reader implementation.
> Maybe GT could borrow their plugins to be more universal?
>
>
> Thanks,
>
>
> Juan
>
>
>
> On 9/9/2021 12:59 AM, Jody Garnett wrote:
>
> It looks like gdalinfo is also indicating there is a problem:
>
> Warning 1: TIFFReadDirectory:Sum of Photometric type-related color
> channels and ExtraSamples doesn't match SamplesPerPixel. Defining
> non-color channels as ExtraSamples.
>
>
> You could try processing the file with gdal2gdal address issue.
>
> You also indicated the image worked with uDig, do you know what version?
> uDig uses geotools so you may be able to try your sample code with an older
> version of the library.
> --
> Jody Garnett
>
>
> On Tue, 7 Sept 2021 at 21:11, Juan Felipe Arjona <jfarj...@jfarjona.com>
> wrote:
>
>> Hello:
>>
>>
>> I am trying to display GeoTiff files obtained from the Sentinel-Hub WMS
>> service (https://apps.sentinel-hub.com) using Geotools.  The service
>> responds with GeoTIFF files, that I can easily open with QGIS 3.20, but
>> Geotools (25.2) complains with:
>>
>>
>> org.geotools.data.DataSourceException: bandOffsets.length is wrong!
>>      at
>> org.geotools.gce.geotiff.GeoTiffReader.<init>(GeoTiffReader.java:279)
>> ~[gt-geotiff-25.2.jar:na]
>>      at
>> org.geotools.gce.geotiff.GeoTiffFormat.getReader(GeoTiffFormat.java:331)
>> ~[gt-geotiff-25.2.jar:na]
>>      at
>> org.geotools.gce.geotiff.GeoTiffFormat.getReader(GeoTiffFormat.java:77)
>> ~[gt-geotiff-25.2.jar:na]
>>      ...
>> Caused by: org.geotools.data.DataSourceException: bandOffsets.length is
>> wrong!
>>      at
>> org.geotools.gce.geotiff.GeoTiffReader.getHRInfo(GeoTiffReader.java:539)
>> ~[gt-geotiff-25.2.jar:na]
>>      at
>> org.geotools.gce.geotiff.GeoTiffReader.<init>(GeoTiffReader.java:265)
>> ~[gt-geotiff-25.2.jar:na]
>>      ... 20 common frames omitted
>> Caused by: java.lang.IllegalArgumentException: bandOffsets.length is
>> wrong!
>>      at
>> java.desktop/javax.imageio.ImageTypeSpecifier$Interleaved.<init>(ImageTypeSpecifier.java:286)
>>
>> ~[na:na]
>>      at
>> java.desktop/javax.imageio.ImageTypeSpecifier.createInterleaved(ImageTypeSpecifier.java:399)
>>
>> ~[na:na]
>>      at
>> it.geosolutions.imageio.plugins.tiff.TIFFDecompressor.getRawImageTypeSpecifier(TIFFDecompressor.java:1027)
>>
>> ~[imageio-ext-tiff-1.3.9.jar:na]
>>      at
>> it.geosolutions.imageioimpl.plugins.tiff.TIFFImageReader.getImageTypes(TIFFImageReader.java:1359)
>>
>> ~[imageio-ext-tiff-1.3.9.jar:na]
>>      at
>> org.geotools.coverage.grid.io.AbstractGridCoverage2DReader.setLayout(AbstractGridCoverage2DReader.java:1164)
>>
>> ~[gt-coverage-25.2.jar:na]
>>      at
>> org.geotools.gce.geotiff.GeoTiffReader.getHRInfo(GeoTiffReader.java:373)
>> ~[gt-geotiff-25.2.jar:na]
>>      ... 21 common frames omitted
>>
>>
>> Gdal says about the file:
>>
>> gdalinfo img-pierrenet-2b9.tif
>> Warning 1: img-pierrenet-2b9.tif: TIFFReadDirectory:Sum of Photometric
>> type-related color channels and ExtraSamples doesn't match
>> SamplesPerPixel. Defining non-color channels as ExtraSamples.
>> Driver: GTiff/GeoTIFF
>> Files: img-pierrenet-2b9.tif
>> Size is 199, 200
>> Coordinate System is:
>> GEOGCRS["WGS 84",
>>      DATUM["World Geodetic System 1984",
>>          ELLIPSOID["WGS 84",6378137,298.257223563,
>>              LENGTHUNIT["metre",1]]],
>>      PRIMEM["Greenwich",0,
>>          ANGLEUNIT["degree",0.0174532925199433]],
>>      CS[ellipsoidal,2],
>>          AXIS["geodetic latitude (Lat)",north,
>>              ORDER[1],
>>              ANGLEUNIT["degree",0.0174532925199433]],
>>          AXIS["geodetic longitude (Lon)",east,
>>              ORDER[2],
>>              ANGLEUNIT["degree",0.0174532925199433]],
>>      ID["EPSG",4326]]
>> Data axis to CRS axis mapping: 2,1
>> Origin = (31.163993000000001,51.090416070349242)
>> Pixel Size = (0.000143449691988,-0.000089870351746)
>> Metadata:
>>    AREA_OR_POINT=Area
>>    TIFFTAG_RESOLUTIONUNIT=1 (unitless)
>>    TIFFTAG_XRESOLUTION=1
>>    TIFFTAG_YRESOLUTION=1
>> Image Structure Metadata:
>>    COMPRESSION=DEFLATE
>>    INTERLEAVE=PIXEL
>> Warning 1: TIFFReadDirectory:Sum of Photometric type-related color
>> channels and ExtraSamples doesn't match SamplesPerPixel. Defining
>> non-color channels as ExtraSamples.
>> Corner Coordinates:
>> Upper Left  (  31.1639930,  51.0904161) ( 31d 9'50.37"E, 51d 5'25.50"N)
>> Lower Left  (  31.1639930,  51.0724420) ( 31d 9'50.37"E, 51d 4'20.79"N)
>> Upper Right (  31.1925395,  51.0904161) ( 31d11'33.14"E, 51d 5'25.50"N)
>> Lower Right (  31.1925395,  51.0724420) ( 31d11'33.14"E, 51d 4'20.79"N)
>> Center      (  31.1782662,  51.0814290) ( 31d10'41.76"E, 51d 4'53.14"N)
>> Band 1 Block=199x10 Type=Byte, ColorInterp=Gray
>> Band 2 Block=199x10 Type=Byte, ColorInterp=Undefined
>> Band 3 Block=199x10 Type=Byte, ColorInterp=Undefined
>> Band 4 Block=199x10 Type=Byte, ColorInterp=Undefined
>>
>>
>> The file can be found at:
>> https://www.dropbox.com/s/xgro5jw35uw59i4/img-pierrenet-2b9.tif?dl=0
>>
>>
>> My code (mostly a copy/paste from ImageLab.java):
>>
>> ...
>>
>>   Path img = Path.of("img-pierrenet-2b9.tif");
>>
>>   AbstractGridFormat format = GridFormatFinder.findFormat(img.toFile());
>>
>>   Hints hints = new Hints();
>>   if (format instanceof GeoTiffFormat) {
>>       hints = new Hints(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER,
>> Boolean.TRUE);
>>   }
>>   reader = format.getReader(img.toFile(), hints);  // Exception is
>> thrown here
>>   Style rgbStyle = createRGBStyle();
>>   mapContent.setTitle("Satellite Images");
>>   Layer layer = new GridReaderLayer(reader, rgbStyle);
>>   mapContent.addLayer(layer);
>>   mapPane.repaint();
>>
>> ...
>>
>>
>> Is there a way to get around this problem  ?
>>
>>
>> Thanks in advance,
>>
>>
>> Juan
>>
>>
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>> GeoTools-GT2-Users mailing list
>> GeoTools-GT2-Users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>>
>
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to