Cannot create subset with snappy


#1

Hi,
I am new to the snappy library and I could not find any helpful documentation regarding my problem.
My problem is following: I can’t manage to create a subset with following code, although I have seen this approach in the internet several times already, but in my case I get a warning message (below the code), resulting that my subset cant be created.

from snappy import ProductIO
from snappy import jpy

path = ‘MER_FRS_2PPBCM20020602_152647_000000592006_00283_01339_0002.N1’
product = ProductIO.readProduct(path)

SubsetOp = jpy.get_type(‘org.esa.snap.core.gpf.common.SubsetOp’)
WKTReader = jpy.get_type(‘com.vividsolutions.jts.io.WKTReader’)
wkt = ‘POLYGON((72.7083453089 -65.804099946, 71.7118430585 -64.7052231235, 71.982073769 -61.8437412417, 72.9904736876 -62.7934148188, 72.7083453089 -65.804099946))’

geom = WKTReader().read(wkt)
op = SubsetOp()
op.setSourceProduct(product)
op.setGeoRegion(geom)
sub_product = op.getTargetProduct()

Running this code gives me following warning message:
WARNING: org.esa.snap.core.gpf.common.SubsetOp: No intersection with source product boundary MER_FRS_2PPBCM20020602_152647_000000592006_00283_01339_0002.N1

EDIT:
those coordinates are within the picture, but still same problem:
wkt = ‘POLYGON((41.405050 -74.640404, 41.405050 -71.508210, 39.855295 -71.508210, 39.855295 -74.640404, 41.405050 -74.640404))’


#2

The error is saying that the coordinates given and the product don’t overlap. Double check that the coordinates are given correctly in lon lat order
These look like they are in the ocean off Antarctica


#3

Hi lveci,
I just have realized that I posted the wrong coordinates.
Those should be within the picture:
wkt = ‘POLYGON((41.405050 -74.640404, 41.405050 -71.508210, 39.855295 -71.508210, 39.855295 -74.640404, 41.405050 -74.640404))’

But it still does’nt work


#4

OK, I just realized that I accidentally used the wrong order (lat lon). Now it works!
So it has to be following instead:
wkt = ‘POLYGON((-74.640404 41.405050, -71.508210 41.405050, -71.508210 39.855295, -74.640404 39.855295, -74.640404 41.405050))’

Thank you very much, lveci!