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}')