|
From: Juan F. A. <jfa...@jf...> - 2021-09-09 19:52:15
|
Thanks Daniele! I have raised the problem as well to the Sentinel-Hub
team. I sent your analysis and their answer is at the bottom of this email.
The image is a satellite image (true color), here is the json that
represents the info:
{
"id": "TRUE-COLOR-S2L2A",
"title": "TRUE COLOR S2L2A",
"description": "Based on bands 4,3,2",
"styles": [
{
"name": "default",
"description": "Default layer style",
"dataProduct": {
"@id":
"https://services.sentinel-hub.com/configuration/v1/datasets/S2L2A/dataproducts/752",
"id": 752,
"name": "TRUE_COLOR.RGB",
"description": "True color image by mapping the red,
green and blue input bands. Value = B04,B03,B02 - RGB visualization.",
"evalScript": "//VERSION=3\n\nlet minVal = 0.0;\nlet
maxVal = 0.4;\n\nlet viz = new HighlightCompressVisualizer(minVal,
maxVal);\n\nfunction evaluatePixel(samples) {\n let val =
[samples.B04, samples.B03, samples.B02];\n val =
viz.processList(val);\n val.push(samples.dataMask);\n return
val;\n}\n\nfunction setup() {\n return {\n input: [{\n bands:
[\n \"B02\",\n \"B03\",\n \"B04\",\n \"dataMask\"\n
]\n }],\n output: {\n bands: 4\n }\n }\n}\n\n",
"dataset": {
"@id":
"https://services.sentinel-hub.com/configuration/v1/datasets/S2L2A"
},
"baseProduct": "TRUE_COLOR",
"visualization": "RGB",
"scriptVersion": 3,
"listed": true,
"additionalData": {
"preV3EquivalentId": 85
}
}
}
],
"orderHint": 8,
"dataset": {
"@id":
"https://services.sentinel-hub.com/configuration/v1/datasets/S2L2A"
},
"datasetSource": {
"@id":
"https://services.sentinel-hub.com/configuration/v1/datasets/S2L2A/sources/2"
},
"defaultStyleName": "default",
"datasourceDefaults": {
"upsampling": "BICUBIC",
"mosaickingOrder": "mostRecent",
"temporal": false,
"maxCloudCoverage": 2,
"previewMode": "PREVIEW",
"type": "S2L2A"
},
"userData": {}
}
------- Their answer: ----------
Yeah, that pretty much confirms what I was saying.
Unfortunately, SentinelHub service cannot know if you are requesting
back a true RGB(+A) image, or is it something else (e.g. B05,B06,B8a,B11
from Sentinel-2). So the decision that 8-bit 4channel image /has/ to be
RGBA generally does not hold true.
Could you please share the WMS call with me (with last half of
instanceId masked)? (you can also DM me)
------------------------------------
Thanks,
Juan
On 9/9/2021 10:28 AM, Daniele Romagnoli wrote:
> Hi Juan,
> As reported by Jody, your TIFF data seems not properly formed.
>
> In the past years, any RGB+4TH band (ie. RGB-IR, RGB-NIR) has been
> handled as RGBAlpha which obviously isn't right.
> So the GT imageio-ext TIFF is nowadays properly parsing additional
> TIFF Tags to make sure that IR isn't handled as a transparent band and
> so on.
>
> The TIFF Specifications reports some info about
> SamplesPerPixels,Extrasamples and their relationship, i.e:
> SamplesPerPixel
> Tag = 277 (115.H) Type = SHORT
> The number of components per pixel.
> This number is 3 for RGB images, unless extra samples are present.
> See the ExtraSamples field for further information.
>
> ExtraSamples Description of extra components.
> Tag = 338 (152.H) Type = SHORT N = m
> Specifies that each pixel has m extra components whose interpretation
> is defined by one of the values listed below. When this field is used,
> the SamplesPerPixel field has a value greater than the
> PhotometricInterpretation field suggests. For example, full-color RGB
> data normally has SamplesPerPixel=3. If SamplesPerPixel is greater
> than 3, then the ExtraSamples field describes the meaning of the extra
> samples. If SamplesPerPixel is, say, 5 then ExtraSamples will contain
> 2 values, one for each extra sample. ExtraSamples is typically used to
> include non-color information, such as opacity, in an image. The
> possible values for each item in the field's value are: 0 =
> Unspecified data 1 = Associated alpha data (with pre-multiplied color)
> 2 = Unassociated alpha data
>
> It might be the case that the sample TIFF doesn't respect some of
> these considerations.
> Whilst GDAL might be fail-tolerant reporting that warning (Warning 1:
> TIFFReadDirectory:Sum of Photometric type-related color channels and
> ExtraSamples doesn't match SamplesPerPixel. Defining non-color
> channels as ExtraSamples),
> the GeoTools TIFF Reader (actually the Imageio-ext-tiff reader) isn't.
>
> Checking your data, the TIFF Tags report:
> Photometric = 0 (MinIsBlack) so it seems like a GrayScale image
> BitsPerSample = 8,8,8,8 so it's actually a 4 bands image.
> SamplesPerPixel = 4 (4 bands indeed)
> but no extraSamples are provided
>
> So I think that it's struggling with having a gray image with 3
> additional unknown samples per pixel.
>
> Do you have any additional knowledge about what is the content of this
> data and what do their bands represent?
>
> Please, let us know.
>
>
> Regards,
>
> Daniele Romagnoli
>
> ==GeoServer Professional Services from the experts!
>
> Visit http://bit.ly/gs-services-us <http://bit.ly/gs-services-us>for
> more information.==Daniele RomagnoliSenior Software
> EngineerGeoSolutions Groupphone: +39 0584 962313fax: +39 0584
> 1660272https://www.geosolutionsgroup.com/
> <https://www.geosolutionsgroup.com/>http://twitter.com/geosolutions_it
> <http://twitter.com/geosolutions_it>-------------------------------------------------------
>
> Con riferimento alla normativa sul trattamento dei dati personali
> (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati
> “GDPR”), si precisa che ogni circostanza inerente alla presente email
> (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui
> conoscenza è riservata al/i solo/i destinatario/i indicati dallo
> scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a
> cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato
> se potesse darmene notizia.This email is intended only for the person
> or entity to which it is addressed and may contain information that is
> privileged, confidential or otherwise protected from disclosure. We
> remind that - as provided by European Regulation 2016/679 “GDPR” -
> copying, dissemination or use of this e-mail or the information herein
> by anyone other than the intended recipient is prohibited. If you have
> received this email by mistake, please notify us immediately by
> telephone or e-mail.
>
>
> On Thu, Sep 9, 2021 at 3:52 PM Juan Felipe Arjona
> <jfa...@jf... <mailto:jfa...@jf...>> wrote:
>
> I added the imageio-ext-tiff plugin in my dependencies, and Java
> ImageIO can open and read the TIFF images, but when using
> GeoTools, the application throws the same Exception.
>
> Juan
>
>
> On 9/9/2021 8:45 AM, Juan Felipe Arjona 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
>> <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
>>> <jfa...@jf... <mailto:jfa...@jf...>> wrote:
>>>
>>> Hello:
>>>
>>>
>>> I am trying to display GeoTiff files obtained from the
>>> Sentinel-Hub WMS
>>> service (https://apps.sentinel-hub.com
>>> <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
>>> <http://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
>>> <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
>>> Geo...@li...
>>> <mailto:Geo...@li...>
>>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>>> <https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users>
>>>
>>
>>
>> _______________________________________________
>> GeoTools-GT2-Users mailing list
>> Geo...@li... <mailto:Geo...@li...>
>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users <https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users>
> _______________________________________________
> GeoTools-GT2-Users mailing list
> Geo...@li...
> <mailto:Geo...@li...>
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
> <https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users>
>
|