S2 resampling OP error

When resampling a S2 product using the resample OP, I randomly get an error and the processing fails.

The detailed error message is as follows:

java.lang.IllegalArgumentException: dataType out of range!
at it.geosolutions.imageio.plugins.tiff.TIFFTag.getSizeOfType(TIFFTag.java:326)
at it.geosolutions.imageioimpl.plugins.tiff.TIFFIFD.initialize(TIFFIFD.java:285)
at it.geosolutions.imageioimpl.plugins.tiff.TIFFImageMetadata.initializeFromStream(TIFFImageMetadata.java:147)
at it.geosolutions.imageioimpl.plugins.tiff.TIFFImageReader.readMetadata(TIFFImageReader.java:664)
at it.geosolutions.imageioimpl.plugins.tiff.TIFFImageReader.seekToImage(TIFFImageReader.java:618)
at it.geosolutions.imageioimpl.plugins.tiff.TIFFImageReader.seekToImage(TIFFImageReader.java:576)
at it.geosolutions.imageioimpl.plugins.tiff.TIFFImageReader.getWidth(TIFFImageReader.java:833)
at org.esa.s2tbx.dataio.jp2.internal.JP2TileOpImage$ImageReader.getImageWidth(JP2TileOpImage.java:306)
at org.esa.s2tbx.dataio.jp2.internal.JP2TileOpImage.computeRectIndirect(JP2TileOpImage.java:166)
at org.esa.s2tbx.dataio.jp2.internal.JP2TileOpImage.computeRect(JP2TileOpImage.java:147)
at javax.media.jai.SourcelessOpImage.computeTile(SourcelessOpImage.java:137)
at com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler.java:904)
Caused: org.esa.snap.core.gpf.OperatorException: dataType out of range!
at org.esa.snap.core.gpf.internal.OperatorExecutor$GPFImagingListener.errorOccurred(OperatorExecutor.java:376)
at com.sun.media.jai.util.SunTileScheduler.sendExceptionToListener(SunTileScheduler.java:1646)
at com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler.java:921)
at javax.media.jai.OpImage.getTile(OpImage.java:1129)
at com.sun.media.jai.opimage.TranslateIntOpImage.getTile(TranslateIntOpImage.java:132)
at javax.media.jai.PlanarImage.getData(PlanarImage.java:2085)
at javax.media.jai.PlanarImage.getExtendedData(PlanarImage.java:2440)
at com.sun.media.jai.opimage.MosaicOpImage.computeTile(MosaicOpImage.java:432)
at com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler.java:904)
at javax.media.jai.OpImage.getTile(OpImage.java:1129)
at com.sun.media.jai.opimage.CropOpImage.getTile(CropOpImage.java:122)
at javax.media.jai.RenderedOp.getTile(RenderedOp.java:2257)
at javax.media.jai.PointOpImage.computeTile(PointOpImage.java:911)
at com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler.java:904)
at javax.media.jai.OpImage.getTile(OpImage.java:1129)
at javax.media.jai.PlanarImage.cobbleDouble(PlanarImage.java:3355)
at javax.media.jai.PlanarImage.getData(PlanarImage.java:2184)
at javax.media.jai.PlanarImage.getExtendedData(PlanarImage.java:2440)
at javax.media.jai.GeometricOpImage.computeTile(GeometricOpImage.java:678)
at com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler.java:904)
at javax.media.jai.OpImage.getTile(OpImage.java:1129)
at javax.media.jai.PointOpImage.computeTile(PointOpImage.java:911)
at com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler.java:904)
at javax.media.jai.OpImage.getTile(OpImage.java:1129)
at javax.media.jai.PlanarImage.cobbleUShort(PlanarImage.java:3052)
at javax.media.jai.PlanarImage.getData(PlanarImage.java:2175)
at com.bc.ceres.glevel.MultiLevelImage.getData(MultiLevelImage.java:64)
at org.esa.snap.core.gpf.internal.OperatorContext.getSourceTile(OperatorContext.java:407)
at org.esa.snap.core.gpf.internal.OperatorContext.getSourceTile(OperatorContext.java:393)
at org.esa.snap.core.gpf.internal.OperatorImage.computeRect(OperatorImage.java:73)
at javax.media.jai.SourcelessOpImage.computeTile(SourcelessOpImage.java:137)
at com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler.java:904)
at javax.media.jai.OpImage.getTile(OpImage.java:1129)
at com.sun.media.jai.util.RequestJob.compute(SunTileScheduler.java:247)
[catch] at com.sun.media.jai.util.WorkerThread.run(SunTileScheduler.java:468)

Settings for resampling were:

  • save as dimap
  • resampling to B6 resolution
  • downsampling method Mean

all other parameters: default

1 Like

Incidentally, I have also observed (quite rare, but still) such “dataType out of range!” exception.
This seems to come from an underlying TIFF reader from the GeoSolutions library.

If you are using SNAP 5.0 (the latest release at the time of writing), you can try to do the following:

  1. Go to your user profile folder and then navigate to ~/.snap/etc (for example, on Windows, it would be something like C:\Users\MyUser\.snap\etc)
  2. There should be a file named s2tbx.properties. Open it with a text editor and add the following line at the end:
    use.openjp2.jna=true
    This will switch to an alternate usage of the OpenJpeg decoder that is supposed to be slightly faster and which doesn’t use the GeoSolutions library.

Then you can try to see if you encounter any exceptions with the resampling operator (or any other operations which imply the reading of Sentinel-2 products).

At any time you can revert to the default behavior by either removing the above line from the s2tbx.properties or by setting it to false.

Hope this will help.

2 Likes

thanks a lot! that solved the problem!

anyhow, that’s still a bug that needs to be fixed.

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.