GeoTIF export of spatially subset image leads to wrong image dimensions and coverage

What I want to do is to subset a Sentinel-2 image, perform some analysis on the subset (e.g. band math) and export the result as GeoTIF.
The first step is to subset the S2 image, taking only bands B6 and B7, both having 20 m resolution. In the Subset Tool window, I specify a ROI based on pixel coordinates.
I select a 20 m band from the reference band list before that of course.
The subset image is not saved as .dim file/product; just opened in SNAP.
Then I generate new band (e.g. MyBand) with Band Maths.
Finally I export MyBand as Geo TIFF. In the Export window I perform only a Band subset (because I need only MyBand, but not B6 and B7). I do not perform spatial subset at that stage because I expect the image is already cropped to my area of interest.
An output image is generated but an error is shown on the lower left corner of SNAP: Unexpected Exception: The specified region, if not null, must intersect with the image’s bounds.
Here are some screenshots of the detailed error message:

Untitled3

And here is the output tiff file opened in QGIS. In the background is the original Sentinel band B6. It can be seen that the upper left corner of the output tiff is aligned well with the area of interest. However the imsge subset should be 3800x2202 pixels while the output tiff is 10980x10980 (i.e. the size of the Sentinel-2 10m bands).


In summary: the spatial subset performed during the first step has no effect during export. Any ideas why this is so?
As a desperate decision, one may want to perform (again) spatial subset during the export. But what turns out is that, somehow, the reference image dimensions are those of a 10 m sentinel band (10980x10980) and you just do not know what values to provide for Scene start/end X/Y. A totall mess.

I am using SNAP 7.

Did you try saving the image after doing the 1st subset?

Hello @Petar,
The band created with Band Maths is a virtual band, that depends on B6 and B7 in your case.
I am guessing you received a warning from SNAP when you wanted to export only your virtual band.
So try exporting to GeoTIFF the entire product containing B6, B7 and the virtual band. (it works without to previously save it as .dim)
The GeoTIFF exported product should keep your ROI subset.

@mengdahl Yes, this was the first thing that came to my mind. I think the error message was different but the result was the same.

Hello @oana_hogoiu ,
In the Band Math window there is a checkbox “Virtual (save expression only, don’t store data)”. I didn’t check this option, so I expect that the band created is not virtual. However I tried to export all bands as you suggested. Unfortunately the result was the same as before.

I actually performed the steps you mentioned in the first post, before to write you the first time, and it worked.
My GeoTIFF exported product has the 500 * 500 region that I chose at first subset.

1/ make sure to properly do the subset:

2/ Check that the subset product has correct ROI:

3/ Add a new band with Band Math

4/ Export the entire subset product as GeoTIFF, and open it in SNAP:

It has the same 500*500 area.

So what are you doing differently? (btw, I am using SNAP 7.0.1)

1 Like

Hello @oana_hogoiu,
thank you for the detailed instructions. I followed them but still without success. One difference with your example is that I am using Level 2A product processed locally with Sen2Cor. So I tried with another images: L2A downloaded from Copernicus hub and L1C. The behavior of SNAP changed a bit: 1) in the subset window, the Source scene width and height was 1830 (not 10980 as before); 2) there was no error message during the export; 3) when the tiff file is opened in SNAP, neither the “new_band_1” (from the band math) nor B6 and B7 are shown correctly (see the image below). Also, even in the tiff file, the icon before “new_band_1” is with “V” indicating a virtual band.
Maybe I will have to reinstalling SNAP to see if this may fix the problem. Thanks for your time, anyway.

I don’t see the subset step in your screenshot…
I see only the initial product and after the exported GeoTIFF product.

Hi,
there was a known problem, but it should be fixed with version 7.0.1 (available since some weeks ago). Have you updated SNAP?
It was caused because the subset operator was not updating the scene geocoding (it kept the geocoding at 10 m) and the GeoTiff writer is using this geocoding instead of the geocoding of the bands (at 20 m).

Hello, @oana_hogoiu,
in fact, the exported tiff was automatically loaded in SNAP and the temporary subset product despaired from the Product Explorer.
This is another strange behavior which I didn’t mentioned in my last comment because I thought it was not directly related with the corrupted tiff issue. Thanks.

Hi, @obarrilero,
No, I haven’t updated SNAP. In this case, maybe I should wait for version 7.0.1 to became available before re-installing. Thank you vary much for the information.

7.0.1 is already available, so you can already update.

Also, I mentioned in my previous post that I am using 7.0.1:

You don’ need to reinstall. You can update it in SNAP: Menu -> Tools -> Plugins …

Hi again @obarrilero,
I updated SNAP through Tools->Plugins. Here is the version info after the update.


It is still 7.0.0.

It is updated properly:

image

Just for information, the updating didn’t resolve the problem.