Obtaining Corner Coordinates (get extent) of the product in snappy?


Is it possible to get information about area covered by the product (corner coordinates) using SNAP API in Python?

I know that I can call other tools such as gdalinfo or GetExtent function described in this thread: http://gis.stackexchange.com/questions/57834/how-to-get-raster-corner-coordinates-using-python-gdal-bindings
However, GDAL do not allow me to easily read all products that are supported by SNAP / snappy.


You could use for example ProductUtils#createGeoBoundary(Product, int)
This will return an array of GeoPos objects.




I am refreshing this topic because I would like to generate the outline of the products I have processed in order to have an overview.

I have used the method createGeoBoundaryPaths.

File = snappy.ProductIO.readProduct('mosaic.dim')
Path =snappy.ProductUtils.createGeoBoundaryPaths(File)

I would assume that I would obtain the 4 corner coordinates of the mosaic. The script proposed by @kedziorm assumes a square scene using min and max of the lat-long which is not valid when your data have been reprojected.

 for point in Path:
    print point.getCurrentPoint().toString()

Returns a single set of coordinates, what am I doing wrong?



The method is named createGeoBoundaryPaths, so you get an array of path. In most cases there will only one but there can be two or three if the product crosses the anti-meridian. Also, this method creates for every ~8th border pixel one location.

Maybe the method GeoPos[] ProductUtils.createGeoBoundary(Product product, int step) is more appropriate for you. It return an GeoPos-array which you can iterate.

If you are only interested in the corner coordinates. You could only ask for them:

ul_Pos = product.getSceneGeoCoding().getGeoPos(PixelPos(0,0), None)
ur_Pos = product.getSceneGeoCoding().getGeoPos(PixelPos(0, product.getgetSceneRasterWidth()-1), None)