Get bbox/WKT from a product subset in python

Hey guys !

Do you know if it is possible to get the geographical location of a product (such as the bbox or the wkt polygon) via the python module ? I was wondering if a product method giving this info exists.

( bbox = product.getBbox() this kind of idea)

Thank you !

Not it is not that straight forward.

You can define GeoUtils by

GeoUtils = jpy.get_type('org.esa.snap.core.util.GeoUtils')

Then you can call:

geoPaths = GeoUtils.createGeoBoundaryPaths(product)

This will return in most cases an array with one element. Only if the product crosses one or multiple times the anti-meridian there will be more.

So, in most cases you can call afterwards:

bounds = geoPaths[0].getBounds2D()

on this you can use

x0 = bounds.getX()
y0 = bounds.getY()
w = bounds.getWidth()
h = bounds.getHeight()

If you have multiple paths you iterate over them and call

union = geoPaths[n].getBounds2D().createUnion(geoPaths[n+1].getBounds2D())

Thank you very much ! I will try this out :slight_smile: