Product sentinel-2 Subset Runtime Error gridWidth >= 2

Hi,
I an trying get a subset of some data Sentinel-2 Level 1 and 2 using Python, but get this error:

org.esa.snap.core.gpf.OperatorException: gridWidth >= 2

This is my function to get subset:

def snap_get_subset(product_snap, wkt_ext):
    SubsetOp = jpy.get_type('org.esa.snap.core.gpf.common.SubsetOp')
    geom = WKTReader().read(wkt_ext)
    op = SubsetOp()
    op.setSourceProduct(product_snap)
    op.setGeoRegion(geom)
    try:
        sub_product = op.getTargetProduct()
    except Exception as errorp:
        print(errorp)
    return sub_product

name_file='S2A_MSIL1C_20220201T012901_N0400_R074_T54SUG_20220201T031559.zip'
wkt_ext='POLYGON ((139.86975641284016 37.4929791239449, 139.86975641284016 37.51435851605785, 139.84280695431656 37.51435851605785, 139.84280695431656 37.4929791239449, 139.86975641284016 37.4929791239449))'
snap_product = ProductIO.readProduct(namefile)
snap_get_subset(snap_product, wkt_ext)

I use this polygon(EPSG:4326) : wkt_ext=‘POLYGON ((139.86975641284016 37.4929791239449, 139.86975641284016 37.51435851605785, 139.84280695431656 37.51435851605785, 139.84280695431656 37.4929791239449, 139.86975641284016 37.4929791239449))’

The Sentinel-2 Data is (Command URL to download, replace user_name:passwd with your credentials):

curl -o S2A_MSIL1C_20220201T012901_N0400_R074_T54SUG_20220201T031559.zip -k -u “user_name:passwd” --limit-rate 30048k “https://catalogue.onda-dias.eu/dias-catalogue/Products(f0fdbba2-c6af-4bd7-a0cd-385bbe689c67)/$value

curl -o S2A_MSIL2A_20220201T012901_N0400_R074_T54SUG_20220201T034937.zip -k -u “user_name:passwd” --limit-rate 30048k “https://catalogue.onda-dias.eu/dias-catalogue/Products(6b991993-b101-49f2-b8ae-cad6707a5cf0)/$value

With other data sentinel-2 work fine, but with S2A_MSIL2A_20220201T012901_N0400_R074_T54SUG_20220201T034937.zip and S2A_MSIL1C_20220201T012901_N0400_R074_T54SUG_20220201T031559.zip not working.

Please, help me.

Hi,
I have the same issue here when trying to subset a S2 L1C data. Any chance you found the source of the problem ?
Maybe @marpet has an idea…
It works with some data but not with all, same as you.
I’m using latest SNAP release 9.0.0.
Thanks

This is a known issue.
[SNAP-1507] Subset cannot be created if tie-point grid is sparse - JIRA (atlassian.net)

You can either increase the region of interest or you can remove the tie-point grids if you don’t need them. How this can be done in a graph is mentioned in the comments of the referenced issue.

Thanks @marpet

I actually just did realize that I was indeed trying to subset a very small area. That confirms it was the issue.

How do you specify to exclude the Tie point grid data in a graph?
I don’t see the option in the lines below:

    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <sourceBands/>
      <region>0,0,0,0</region>
      <referenceBand/>
      <geoRegion>POLYGON((10.4163 51.1017,10.488 51.1017,10.488 51.0567,10.4163 51.0567,10.4163 51.1017))
</geoRegion>
      <subSamplingX>1</subSamplingX>
      <subSamplingY>1</subSamplingY>
      <fullSwath>false</fullSwath>
      <tiePointGridNames/>
      <copyMetadata>true</copyMetadata>
    </parameters>

Hi Christophe,
do it like this:

<tiePointGrids>,</tiePointGrids>

1 Like