S2 Resampling Error "Failed to Read Data for level 0 and rectangle"

Hello,

I’m having an error with the latest SNAP version and I can’t resample with the Sentinel-2 tool… I would like your opinion on how to fix this.

File used:
https://scihub.copernicus.eu/dhus/odata/v1/Products('55e698bc-6036-4268-b6b0-86ac0109ae8a')/$value

Optical → Geometric → S2 Resampling Processor

Error: Shown in Picture. Replicated with 2 different computers and 2 different files.

Additional Questions: What is the difference between “S2 Resampling Processor” and “Raster → Geometric → Resampling”. I’m trying to do atmospheric correction with C2RCC.


Screenshot 2022-09-25 170547
Screenshot 2022-09-25 170606

This is an error which occurs since a while but not always. This makes it difficult to hunt down this bug.
Maybe @FlorianD has more insight on this.

Regarding the difference between the two resampling. The viewing angles need to be considered special for S2 data. This is done by the S2 Resampling tool. This is explained in the help.

1 Like

Hello,
I tested with your product and obtained the same errors.
It seems to come from the underlying TIFF reader from GeoSolutions library.
The only way I could escape from the error was to edit s2tbx.properties (located under C:\Users\your_username.snap\etc) by adding
use.openjp2.jna=true
This way the S2 Resampling worked:

You may also check:

1 Like

I tested both!

  1. Adding “use.openjp2.jna=true” to the top of the s2tbx.properties file without changing the output name: WORKED

  2. Not modifying the s2tbx.properties file and changing the output name to “shortName_resampled”: FAILED

I believe that the name shortening seemed to work on the other post but I’ll stick to the modification of the s2tbx.properties file for now.

Thanks! Is there a way to submit a bug report for this?

Below the Error Log for the FAILED experiment #2 in case it’s of use for later reference

java.io.EOFException
	at javax.imageio.stream.ImageInputStreamImpl.readShort(ImageInputStreamImpl.java:229)
	at javax.imageio.stream.ImageInputStreamImpl.readUnsignedShort(ImageInputStreamImpl.java:242)
	at it.geosolutions.imageioimpl.plugins.tiff.TIFFIFD.initialize(TIFFIFD.java:241)
	at it.geosolutions.imageioimpl.plugins.tiff.TIFFImageMetadata.initializeFromStream(TIFFImageMetadata.java:148)
	at it.geosolutions.imageioimpl.plugins.tiff.TIFFImageReader.readMetadata(TIFFImageReader.java:911)
Caused: javax.imageio.IIOException: I/O error reading image metadata!
	at it.geosolutions.imageioimpl.plugins.tiff.TIFFImageReader.readMetadata(TIFFImageReader.java:917)
	at it.geosolutions.imageioimpl.plugins.tiff.TIFFImageReader.seekToImage(TIFFImageReader.java:864)
	at it.geosolutions.imageioimpl.plugins.tiff.TIFFImageReader.seekToImage(TIFFImageReader.java:822)
	at it.geosolutions.imageioimpl.plugins.tiff.TIFFImageReader.getWidth(TIFFImageReader.java:1080)
	at org.esa.snap.jp2.reader.internal.JP2TileOpImage$ImageReader.getImageWidth(JP2TileOpImage.java:306)
	at org.esa.snap.jp2.reader.internal.JP2TileOpImage.computeRectIndirect(JP2TileOpImage.java:148)
	at org.esa.snap.jp2.reader.internal.JP2TileOpImage.computeRect(JP2TileOpImage.java:113)
Caused: java.lang.IllegalStateException: Failed to read the data for level 0 and rectangle java.awt.Rectangle[x=0,y=0,width=256,height=256].
	at org.esa.snap.jp2.reader.internal.JP2TileOpImage.computeRect(JP2TileOpImage.java:115)
	at javax.media.jai.SourcelessOpImage.computeTile(Unknown Source)
Caused: org.esa.snap.core.gpf.OperatorException: Failed to read the data for level 0 and rectangle java.awt.Rectangle[x=0,y=0,width=256,height=256].
	at org.esa.snap.core.gpf.internal.OperatorExecutor$GPFImagingListener.errorOccurred(OperatorExecutor.java:381)
	at com.sun.media.jai.util.SunTileScheduler.sendExceptionToListener(Unknown Source)
	at com.sun.media.jai.util.SunTileScheduler.scheduleTile(Unknown Source)
	at javax.media.jai.OpImage.getTile(Unknown Source)
	at com.sun.media.jai.opimage.TranslateIntOpImage.getTile(Unknown Source)
	at javax.media.jai.PlanarImage.getData(Unknown Source)
	at javax.media.jai.PlanarImage.getExtendedData(Unknown Source)
	at com.sun.media.jai.opimage.MosaicOpImage.computeTile(Unknown Source)
	at com.sun.media.jai.util.SunTileScheduler.scheduleTile(Unknown Source)
	at javax.media.jai.OpImage.getTile(Unknown Source)
	at javax.media.jai.PlanarImage.cobbleByte(Unknown Source)
	at javax.media.jai.PlanarImage.getData(Unknown Source)
	at javax.media.jai.RenderedOp.getData(Unknown Source)
	at com.bc.ceres.glevel.MultiLevelImage.getData(MultiLevelImage.java:64)
	at org.esa.snap.core.gpf.internal.OperatorContext.getSourceTile(OperatorContext.java:449)
	at org.esa.snap.core.gpf.internal.OperatorContext.getSourceTile(OperatorContext.java:435)
	at org.esa.snap.core.gpf.internal.OperatorImage.computeRect(OperatorImage.java:75)
	at javax.media.jai.SourcelessOpImage.computeTile(Unknown Source)
	at com.sun.media.jai.util.SunTileScheduler.scheduleTile(Unknown Source)
	at javax.media.jai.OpImage.getTile(Unknown Source)
	at com.sun.media.jai.util.RequestJob.compute(Unknown Source)
[catch] at com.sun.media.jai.util.WorkerThread.run(Unknown Source)

Edit: Typos

Thanks, even for me the second case didn’t worked.
The error is still coming from the underlying TIFF reader from GeoSolutions library. (which is external to SNAP). The workaround is just to avoid it.

Alright! Thanks for the help :slight_smile:

We also created a ticket for this issue, for further investigation and possible workaround: SIITBX-501

Hello,I obtained the same errors,but in the (located under C:\Users\your_username.snap\etc),I didn’t find the s2tbx.properties ,so can you help me, I can’t proceed to the next step.

Hello @yaoyao,
What is your SNAP version? With SNAP 9, the file C:\Users\username_name\.snap\etc\s2tbx.properties is created when SNAP is started.