How to get product footprint

Is there some way to read the image footprint from the Sentinel-2 XML file? Something like the individual detector footprints …

…just for the entire image?

What I tried:
There is an entry in the XML file that contains a list of coordinates:

<n1:Geometric_Info> <Product_Footprint> <Product_Footprint> <Global_Footprint> <EXT_POS_LIST> 55.0369285878196 4.564772712281186 [...] </EXT_POS_LIST> </Global_Footprint> </Product_Footprint> <RASTER_CS_TYPE>POINT</RASTER_CS_TYPE> <PIXEL_ORIGIN>1</PIXEL_ORIGIN> </Product_Footprint>

However, this EXT_POS_LIST does not just contain the (5, in the case above) footprint corners, but several dozen points that seem to correspond in no way to the product footprint and that seem to entirely lie outside the scene boundaries.

I called gdalinfo <productfile>.xml and received the following (shortened) output:

`Driver: SENTINEL2/Sentinel 2
Files: S2A_USER_MTD_SAFL2A_PDMC_20160331T203110_R008_V20160329T104105_20160329T104105.xml
Size is 512, 512
Coordinate System is ``’
FOOTPRINT=POLYGON((4.564772712281186 55.0369285878196, 4.56306749842358 54.99183735511474, […snip…]))

I then copied the FOOTPRINT data into a CSV file:

org.esa.snap.Polygon Name:String Geometry:Polygon 0 footprint POLYGON((4.564772712281186 55.0369285878196, [...snip...]))

… and QGIS showed a shape that looked like this:

… while the import into SNAP …

… gave this error:

So: how can I (preferably via GDAL or just parsing the XML product file) read the footprint of a Sentinel-2 product? Am I missing something painfully obvious?

Hi @ChristianSeverin

I doubt the EXT_POS_LIST includes info about the actual detector footprint.
I have not checked on my own, but I bet it is more delineating the contours of all L1C/L2A tiles, including nodata area.

The detector footprint info are stored, for each tile, in the QI_DATA folder, in the DETFOO files.
You will have to get it from there, and compute the union for all tiles to get the global detector footprint for your full product.
Basically that’s what we do in SNAP to compute the detector_fooprint masks.

Hopefully for you, ogrinfo seem to recognize those files.

1 Like

You are correct: when I compare the shape of that footprint to the UTM tiles for my granules, I can see that they fit:

I’ll try your “merge DETFOO files” approach then, thanks!

Looks like the “convexhull” of your set of granule footprints is exactly the FOOTPRINT in your CSV file,. The scene footprint is also included in the metadata that you can scrape from apihub (as GML even). What’s the product ID for this scene?

The ID hash in the search result was
(I’m using this as a directory name instead of the too-long original title);
the title of the product is

Try this:

wget -O test.xml --user=USER --password=PWD“S2A_OPER_PRD_MSIL1C_PDMC_20160331T203110_R008_V20160329T104105_20160329T104105*”

test.xml will have a footprint (WKT polygon) and gmlfootprint (GML version of the same), which displays as in attachment (i.e. the convexhull of the granule tiles included in this scene). Ugly, but logical. DETFOO xml per granule should get you something nicer, esp. if you can apply convexhull on the union of their geometries (postgis, what else…).

Yes, I know how to get the union of the UTM tiles that cover a given Sentinel product. That does not, however, help me to easily determine which shapes in a third-party shapefile are entirely within the detector boundary of the product.

Again: what I'd like is the image footprint; something like the corner coordinates of a DETFOO mask for the _entire product_

– preferably without iterating through the entire product filestructure, and parsing every granule’s *DETFOO*.gml files, and creating OGRPolygons from lists of points, and building their OGRGeometry::Union(), and building the OGRGeometry::ConvexHull().

And besides, I don’t have PostGIS installed, only GDAL.