0

I am trying to process large GeoTIFF images using GeoTIFF reader provided by Geotools library. However while processing the image getting below error:

org.geotools.data.DataSourceException: bandOffsets.length is wrong!    at org.geotools.gce.geotiff.GeoTiffReader.getHRInfo(GeoTiffReader.java:502) ~[gt-geotiff-21.2.jar:na]
    at org.geotools.gce.geotiff.GeoTiffReader.<init>(GeoTiffReader.java:253) ~[gt-geotiff-21.2.jar:na]

Below is my code and Gdal info of the image:

Code:

GeoTiffReader geoTiffReader = new GeoTiffReader(s3Object.getObjectContent());
GridCoverage2D gridCoverage = geoTiffReader.read(null);

Gdal info:

→ gdalinfo /vsis3/********/GeoTiff/SampleColor.tif
Warning 1: TIFFReadDirectory:Sum of Photometric type-related color channels and ExtraSamples doesn't match SamplesPerPixel. Defining non-color channels as ExtraSamples.
Driver: GTiff/GeoTIFF
Files: /vsis3/********/GeoTiff/SampleColor.tif
Size is 13470, 8670
Coordinate System is:
PROJCS["WGS 84 / UTM zone 11N",
    GEOGCS["WGS 84",
        DATUM["WGS_1984",
            SPHEROID["WGS 84",6378137,298.257223563,
                AUTHORITY["EPSG","7030"]],
            AUTHORITY["EPSG","6326"]],
        PRIMEM["Greenwich",0,
            AUTHORITY["EPSG","8901"]],
        UNIT["degree",0.0174532925199433,
            AUTHORITY["EPSG","9122"]],
        AUTHORITY["EPSG","4326"]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",0],
    PARAMETER["central_meridian",-117],
    PARAMETER["scale_factor",0.9996],
    PARAMETER["false_easting",500000],
    PARAMETER["false_northing",0],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]],
    AXIS["Easting",EAST],
    AXIS["Northing",NORTH],
    AUTHORITY["EPSG","32611"]]
GeoTransform =
  669778.3831978224, -0.01210218531089629, 0.1262852605635838
  3989755.653826586, 0.1262852605635838, 0.01210218531089629
Metadata:
  AREA_OR_POINT=Area
  TIFFTAG_DATETIME=2018:07:21 11:46:07
  TIFFTAG_IMAGEDESCRIPTION=UltraCam-Lvl03
------------------------------------
  TIFFTAG_RESOLUTIONUNIT=1 (unitless)
  TIFFTAG_SOFTWARE=UltraMap Image Export 24.3.1806.401
Image Structure Metadata:
  INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left  (  669778.383, 3989755.654) (115d 6'55.64"W, 36d 2'15.16"N)
Lower Left  (  670873.276, 3989860.580) (115d 6'11.83"W, 36d 2'17.87"N)
Upper Right (  669615.367, 3991456.716) (115d 7' 0.84"W, 36d 3'10.44"N)
Lower Right (  670710.260, 3991561.642) (115d 6'17.02"W, 36d 3'13.16"N)
Center      (  670244.322, 3990658.648) (115d 6'36.33"W, 36d 2'44.16"N)
Band 1 Block=13470x1 Type=Byte, ColorInterp=Red
Band 2 Block=13470x1 Type=Byte, ColorInterp=Green
Band 3 Block=13470x1 Type=Byte, ColorInterp=Blue
Band 4 Block=13470x1 Type=Byte, ColorInterp=Undefined

Can anyone suggest what's the issue and resolution?

  • probably a broken tiff - see "Warning 1: TIFFReadDirectory:Sum of Photometric type-related color channels and ExtraSamples doesn't match SamplesPerPixel. Defining non-color channels as ExtraSamples." – Ian Turton Jul 26 at 13:26
  • Agreed, but there are other images with similar warning which GeoTiffReader is able to read. Only difference is the type the above one is "Byte" whereas the latter is "UInt16" – Pramod91 Jul 26 at 14:06
  • It is probably reading them badly but this one runs out of data so you get an error – Ian Turton Jul 26 at 14:20
  • Is it possible to read this image using some parameters passed to the GeoTiffReader. – Pramod91 Jul 26 at 14:55
  • I would guess not, reading broken images is outside the scope of GeoTools – Ian Turton Jul 27 at 8:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.