Subset error: gridHeight >=2

Hello,
in the last months I have always used subset without problem but right now, after a month without opening SNAP, I’m having problem using subset because it gives me “gridHeight >=2” error. The fact is that it shows this error only if I try to use subset in my region of interest, if I use subset in another zone of the image it works without problem.

I installed SNAP in two different computers and right now in both I have the same error.

I have already tried to clean the cache because to me it seems there’s something in the memory that stop the process when it is used in that region but it didn’t work. I also tried uninstalling SNAP and installing it again but it gives me always the same error only for that region of the image. I sent the images to another user to check if they are the problem but on another pc it does not report the error.

Do you have any suggestion?
Thanks for the help.

This sounds like as if the overlap of the product boundary with the region you specify is very small.
Did the others you have sent the images to also used the same region?
Can you increase your region of interest a bit?

Yes, the region that I need is really small but in the past I hadn’t problem subsetting it in other images.

Also yes, the others used the coordinates I gave them for the subset without errors. Actually I installed SNAP on the second computer because the first one started reporting this error and I thought it was a problem of my pc. With the second computer I worked without problem for a period and then it started giving me the same error as the first computer.

I have just tried to increse the region of interest and the subset works but I really need the small region because I have to put it in another programme.
Thank you.

It’s strange that the result is varying over time.
Are you using Sentinel-2 data?
This error only occurs when tie-point data is present in the product. Two pixels in both directions are necessary for the interpolation of the tie-points.
But Sentinel-2 does not have tie-points.

Yes I’m sure they are Sentinel-2 data. I downloaded them from Copernicus Open Access Hub: mission sentinel-2, satellite platfrom S2A/B, product type S2MSI2A.

This is the reason I don’t understand why it is not working. Also because I tried to subset the images with which I worked in the past and now I cannot subset them anymore. At first I thought it was my computer but now having two computers with the same error I don’t know what it could be.

I don’t know if this can help but it is the error that occurr:

java.lang.IllegalArgumentException: gridHeight >= 2
at com.bc.ceres.core.Assert.argument(Assert.java:67)
at org.esa.snap.core.datamodel.TiePointGrid.(TiePointGrid.java:104)
at org.esa.snap.core.datamodel.TiePointGrid.(TiePointGrid.java:198)
at org.esa.snap.core.datamodel.TiePointGrid.(TiePointGrid.java:139)
at org.esa.snap.core.datamodel.TiePointGrid.createSubset(TiePointGrid.java:1040)
at org.esa.snap.core.dataio.ProductSubsetBuilder.addTiePointGridsToProduct(ProductSubsetBuilder.java:703)
at org.esa.snap.core.dataio.ProductSubsetBuilder.createProduct(ProductSubsetBuilder.java:511)
at org.esa.snap.core.dataio.ProductSubsetBuilder.readProductNodesImpl(ProductSubsetBuilder.java:270)
at org.esa.snap.core.dataio.AbstractProductReader.readProductNodes(AbstractProductReader.java:178)
at org.esa.snap.core.dataio.AbstractProductBuilder.readProductNodes(AbstractProductBuilder.java:78)
at org.esa.snap.core.dataio.ProductSubsetBuilder.createProductSubset(ProductSubsetBuilder.java:71)
at org.esa.snap.core.dataio.ProductSubsetBuilder.createProductSubset(ProductSubsetBuilder.java:65)
at org.esa.snap.core.datamodel.Product.createSubset(Product.java:1840)
[catch] at org.esa.snap.rcp.subset.CreateSubsetAction.createSubset(CreateSubsetAction.java:104)
at org.esa.snap.rcp.subset.CreateSubsetAction.actionPerformed(CreateSubsetAction.java:73)
at org.openide.awt.InjectorExactlyOne.actionPerformed(InjectorExactlyOne.java:78)
at org.openide.awt.ContextAction$Performer.actionPerformed(ContextAction.java:226)
at org.openide.awt.ContextManager.actionPerformed(ContextManager.java:260)
at org.openide.awt.ContextAction.actionPerformed(ContextAction.java:109)
at org.openide.util.actions.ActionInvoker$1.run(ActionInvoker.java:93)
at org.openide.util.actions.ActionInvoker.doPerformAction(ActionInvoker.java:116)
at org.openide.util.actions.ActionInvoker.invokeAction(ActionInvoker.java:99)
at org.openide.awt.GeneralAction$BaseDelAction.actionPerformed(GeneralAction.java:234)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
at com.jidesoft.plaf.vsnet.VsnetMenuItemUI.doClick(VsnetMenuItemUI.java:1395)
at com.jidesoft.plaf.vsnet.VsnetMenuItemUI$MouseInputHandler.mouseReleased(VsnetMenuItemUI.java:1190)
at java.awt.Component.processMouseEvent(Component.java:6539)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6304)
at java.awt.Container.processEvent(Container.java:2239)
at java.awt.Component.dispatchEventImpl(Component.java:4889)
at java.awt.Container.dispatchEventImpl(Container.java:2297)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4904)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4535)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4476)
at java.awt.Container.dispatchEventImpl(Container.java:2283)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:760)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)
at java.awt.EventQueue$4.run(EventQueue.java:733)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:730)
at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:159)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

Hi there,
I have the same issue and it has only become a problem in the last month or two as well, and now we have multiple areas exhibiting this problem.
I am using latest snappy add-in with python 3.6.
Basically it appears on some products where smaller subsets (I think) will fail with the gridHeight>=2 error these areas are still many square km, so not that small.
I have extracted out problem subsets and tiles and experimented but the failure seems fairly random to me, after increasing the size to some arbitrary amount it suddenly starts working. As we have an automation approach on multiple AOI this is a problem, especially given most products work fine on the original area.

I have a sample script below where you can swap out the footprints and the products and see the error either happening or not happening, and in all cases the subsets are within the full boundary and not particularly small.

Any suggestions would be appreciated.

Thanks.

test_subset.py (2.3 KB)


import snappy

from snappy import (ProductIO, ProductUtils, ProgressMonitor, WKTReader, HashMap, Rectangle, GPF)

jpy = snappy.jpy

# your product location

location = "f:/tiles"

# THIS ONE WORKS FINE

#productName = "S2B_MSIL2A_20190129T222539_N0211_R029_T59GPM_20190130T000902.zip"  

# THIS ONE IS BROKEN

productName = "S2A_MSIL2A_20190203T222531_N0211_R029_T59GPN_20190203T235358.zip"

product = ProductIO.readProduct(f"{location}/{productName}")

#outerFootprint = aq.getFullWktFromProduct(product)  # removed this dependency but the result is pasted below for reference

outerFootprint = 'POLYGON((172.2160 -42.4457,173.5913 -42.4457,173.5913 -43.4116,172.2160 -43.4116,172.2160 -42.4457))'

# subset

#broken - test case 1: using our required subset which fails

footprint = "POLYGON((172.6390010317605 -43.39579965983345,172.6390010317605 -43.344306818076774,172.6958284962738 -43.344306818076774,172.6958284962738 -43.39579965983345,172.6390010317605 -43.39579965983345))"

#works - this one works and is slightly bigger

#footprint = "POLYGON((172.61475357016883 -43.302184842665156,172.69852432212195 -43.302184842665156,172.69852432212195 -43.36810997853914,172.61475357016883 -43.36810997853914,172.61475357016883 -43.302184842665156))"

#broken - slightly smaller than above but breaks with the same error

#footprint = 'POLYGON((172.63397964438758 -43.32316878539379,172.6957777400907 -43.32316878539379,172.6957777400907 -43.36910829381515,172.63397964438758 -43.36910829381515,172.63397964438758 -43.32316878539379))'

# not sure that we need to resample first, but it doesn't seem to make any difference to the error

parameters = HashMap()    

parameters.put('referenceBand', 'B2')

resampled = GPF.createProduct('Resample', parameters, product)

parameters.clear()

parameters.put('geoRegion', footprint)

# ERRROR:  org.esa.snap.core.gpf.OperatorException: gridHeight >= 2

region = GPF.createProduct('Subset', parameters, resampled)  # can swap out resampled for product here, makes no difference to the error.

b = region.getBand('B2')

if b == None:

    print("Band B2 is missing")

else:

    width = b.getRasterWidth()

    height = b.getRasterHeight()

    print(f'New region is {width} by {height}')

This is a known issue: [SNAP-1507] Subset cannot be created if tie-point grid is sparse
But I’m surprised that this happens even after resampling.
If you don’t need the tie-points you can add an empty list as parameter for tiePointGrids for the subset step.
parameters.put('tiePointGrids', ',')
An empty string is not working, this is evaluated to ‘no information’ and then all tie-point grids are included. But this empty list seems to work.

1 Like

Excellent, thanks this solved my issue.

1 Like

I am facing the same issue working in GPT not snappy. How should I implement :

parameters.put('tiePointGrids', ',') in my subset gpt graph?

image

If you change
<tiePointGridNames/>
to
<tiePointGridNames>,</tiePointGridNames>
it should work

@marpet thanks, that error does not appear anymore but now i have

Error: Failed to read the data for level 0 and rectangle java.awt.Rectangle[x=0,y=0,width=38,height=128].

I see it has been reported before. Is there a solution?

Only option I can suggest is to use the S2Resampling, if you use resampling in your graph.
Maybe you can split the graph in two graphs and run them one after the other

@marpet
I have tried with S2resampling but it is extremly slow. Is this normal? Maybe I am missing something to speed it up? The parameters I am setting on that case are 10 m and Nearest.

I have tried to skip the subset process even if data volume is much bigger but when I run only resample in my graph I get the same error too.

Any suggestions? Is this a general bug affecting everybody?

I’m not sure if it affects everybody. But at least some people with at least some data products.
But in house we process quite a lot S2 data and in general it works.

@marpet
For comparison, could you please share a prouduct ID which you have succesfully processed and the gpt graph and SNAP version you have used. My processing steps are resample → subset only

Just to discard if its my SNAP installation or a data issue

I just used this graph: S2_S2Resampling_Subset.xml (1.0 KB)
This is the command line call:
gpt "H:\_graphXML\S2_S2Resampling_Subset.xml" -PsourceFile="H:\SENTINEL2\S2B_MSIL1C_20220619T163839_N0400_R126_T15RYN_20220619T184913.SAFE" -PtargetPath="H:\_temp\S2A_MSS2B_MSIL1C_20220619T163839_Res20_subset.dim"

I am running into this issue as well. I’m using GPT to Resample, Subset and BandMath S2 imagery. My graph had the line

<tiePointGrids/>

so I changed it to

<tiePointGrids>,</tiePointGrids>’

and it worked. Thank you very much for the tip!

This is the size of the area I was trying to subset to:

2 Likes

I had the same problem and changed:
<tiePointGridNames/>
to:
<tiePointGridNames>,</tiePointGridNames>
and it worked! Thank you!!

2 Likes

I had the same problem - a subset that worked before was not possible to process any more. In the GUI, I unchecked all boxes in “Tie-Point Grid Subset” and it worked.

1 Like