Resampling L2A products

Hello!

I have run into quite a bizarre problem when resampling atmospherically corrected Sentinel-2 images to 10m resolution.
The output format is GeoTIFF-BigTIFF, but when I start the process, the file just gets bigger and bigger, until it fills up my entire free memory (~150gb), terminates the process and shows the following error text:

java.io.IOException: There is not enough space on the disk
at java.io.RandomAccessFile.writeBytes(Native Method)
at java.io.RandomAccessFile.write(Unknown Source)
at javax.imageio.stream.FileImageOutputStream.write(Unknown Source)
at it.geosolutions.imageioimpl.plugins.tiff.TIFFNullCompressor.encode(TIFFNullCompressor.java:104)
at it.geosolutions.imageioimpl.plugins.tiff.TIFFImageWriter.writeTile(TIFFImageWriter.java:2506)
at it.geosolutions.imageioimpl.plugins.tiff.TIFFImageWriter.write(TIFFImageWriter.java:2920)
Caused: javax.imageio.IIOException: I/O error writing TIFF file!
at it.geosolutions.imageioimpl.plugins.tiff.TIFFImageWriter.write(TIFFImageWriter.java:2954)
at it.geosolutions.imageioimpl.plugins.tiff.TIFFImageWriter.write(TIFFImageWriter.java:2614)
at org.esa.snap.dataio.bigtiff.BigGeoTiffProductWriter.writeBandRasterData(BigGeoTiffProductWriter.java:195)
at org.esa.snap.core.gpf.common.WriteOp.writeTileRow(WriteOp.java:398)
at org.esa.snap.core.gpf.common.WriteOp.computeTile(WriteOp.java:316)
Caused: org.esa.snap.core.gpf.OperatorException: Not able to write product file: ‘F:\Sentinel2\S2A_USER_MTD_SAFL2A_PDMC_20160523T144413_R079_V20160523T095404_20160523T095404_resampled.tif’
at org.esa.snap.core.gpf.common.WriteOp.computeTile(WriteOp.java:350)
at org.esa.snap.core.gpf.internal.OperatorImage.computeRect(OperatorImage.java:80)
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: Not able to write product file: ‘F:\Sentinel2\S2A_USER_MTD_SAFL2A_PDMC_20160523T144413_R079_V20160523T095404_20160523T095404_resampled.tif’
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.util.RequestJob.compute(SunTileScheduler.java:247)
[catch] at com.sun.media.jai.util.WorkerThread.run(SunTileScheduler.java:468)

I am pretty sure that a resampled S2 L2A image should not take up 150 gb.

When I resample L1C products, however, it goes smoothly and within an hour I get my result.
Is there a workaround for this? I would like to do some biophysical calculations, but I cannot do them with L2A images, because SNAP requires them to be resampled to a single resolution.

Any help greatly appreciated. :slight_smile:

Are you using the desktop app or gpt? Can you show us your resample configuration and in case of gpt the command line call?
On the first look, it sounds to me like the wrong resolution is specified.

I am using the desktop application for resampling. Would using the command line help? If so, what would be the correct command?

Here are the resampling parameters. Pretty much default.

Running it from the command line will not help.

I’ve calculated the raw size of a L2A product in GeoTiff. It is 243 GB.
The reason for this is that we have to use a common data type for all bands.

You can reduce the size for example by removing all the view bands for the specific bands and keep only the mean bands.
Also you can split your product into 2 products. One for the sun/view bands and one for the other bands.
Then the sun/view bands are stored as float32 data type and the other as uint16.

Additionally you can enable a lossless compression for the BigGeotiff.
Add to the snap.properties file (in installdir/etc) the following line:
snap.dataio.bigtiff.compression.type=LZW

2 Likes

Thank you, I did not know that bands other than the main spectral ones have to be resampled aswell. This solves the problem.

Also, on a bit unrelated note - would it be possible to discern which bands are necessary for the fAPAR calculation? The help menu does give some insight on this, but not on the specific sun and view angle bands that are necessary. Just so that I would know which bands I need to resample. Thanks in advance!

As far as I can tell, these are the bands which are used:

B3, B4, B5, B6, B7, B8A, B11, B12
view_zenith_mean, sun_zenith, sun_azimuth, view_azimuth_mean
3 Likes

Thank you, this worked! The processing time is quite long, but everything works as intended.
Great support from you, Marco!