Hi, I’m very new to snappy and SNAP in general
I have been attempting to subset small regions from Sentinel-2 products (crop fields). I have come into the following error when using snappy and I suspect the issue is the co-ordinates are rounded up to fewer decimal places making them identical and therefore making the height and width of the polygon equal to zero.
Having a look at subsets in the SNAP toolbox I see that geo co-ordinates are only taken up to 3 decimal places.
Below is my source code
product = ProductIO.readProduct(r'Path to product')
SubsetOp = snappy.jpy.get_type('org.esa.snap.core.gpf.common.SubsetOp')
wkt = str(df.iloc[0,-1])
geom = WKTReader().read(wkt)
op = SubsetOp()
op.setSourceProduct(product)
op.setGeoRegion(geom)
op.setCopyMetadata(True)
subset = op.getTargetProduct()
ProductIO.writeProduct(subset, "test_subset.dim", "BEAM-DIMAP")
The dataframe cell ‘df.iloc[0,-1]’ returns the following:
POLYGON ((0.5989372730255127 51.106129010265214, 0.6025421619415282 51.106129010265214, 0.6025421619415282 51.10731460488895, 0.5989372730255127 51.10731460488895, 0.5989372730255127 51.106129010265214))
This results in the following error:
---> 12 subset = op.getTargetProduct()
RuntimeError: org.esa.snap.core.gpf.OperatorException: The pixel region 'java.awt.Rectangle[x=10,y=6,width=0,height=0]' is invalid.
Is there any way for me to crop such a small chunk from a Sentinel-2 product?