Tips and tutorials for GIS and Remote Sensing…

Convert Sentinel-2 Data Using GDAL

The latest version of GDAL (2.1) has a driver to read Sentinel 2 data (see http://gdal.org/frmt_sentinel2.html). Like HDF files they are read as subdatasets. Running ‘gdalinfo’ on the zipped folder or the .xml file contained within the .SAFE directory will display all the subdatasets, as well as all the metadata (so quite a lot of information!).

As with HDF5 you can pass the subdataset names to gdalinfo to get more information or gdal_translate to extract them as a separate dataset.

To get the extension for all supported drivers, and some creation options the ‘get_gdal_drivers’ module from arsf_dem_scripts is optionally used. You can just download this file and copy into the same directory ‘extract_s2_data.py’ has been saved to. For Linux or OS X you can run:

Post navigation

7 thoughts on “Convert Sentinel-2 Data Using GDAL”

ESA changed their file naming convention on 6th of December 2016 but their metadata files have also changed, i.e. there is no band list (!!!). This means that gdal.Open throws back an error “ERROR 1: Cannot find Query_Options.Band_List” and therefore cannot get a list of subdatasets from the zip files. I was also using gdal to extract Sentinel-2 data for processing, so any ideas on a way round this would be much appreciated.

That’s quite annoying – I wasn’t aware of this (haven’t looked at Sentinel-2 data with GDAL for a bit). Hopefully the GDAL driver will be updated at some point. If I find a work around I’ll update the post – let me know if you find one first.

Hello , Thanks for sharing this page, I was able to convert sentinel bands from jp2 to tiff format. Values differ slightly b/w jp2 and tiff when i open them in Qgis. However, I want to process the bands in python and when I open the same geotiff in python, a whole diff range of values appear which is much higher range. I believe some basic step (say normalization) is required to be able to use these gdal created geotiff in python. Please suggest. (sorry if the query sounds too basic), thanks in advance