I am trying to create a warped VirtualRaster of a Sentinel2 image. Here the Python code I tried:

from osgeo import gdal, osr

srs = osr.SpatialReference()

d = gdal.Open('SENTINEL2_L1C:S2A_OPER_MTD_SAFL1C_PDMC_20160506T205836_R122_V20160506T100527_20160506T100527.xml:10m:EPSG_32632')
vrt = gdal.AutoCreateWarpedVRT(d, None, srs.ExportToWkt())
gdal.GetDriverByName('VRT').CreateCopy('test.vrt', vrt)

The AutoCreateWarpedVRT command actually succeedes, i.e. the returned dataset can be effectively used to read data and metadata.

The problem arises with the last command, which raises the following exception:

RuntimeError: No such file or directory

Please notice that:

  • The test.vrt file is actually created and filled, but gdal.Open raises the very same error as above (I suspect that the error raised by CreateCopy is actually raised by an internal gdal.Open)
  • If I inject some error in the XML, gdal.Openraises a different exception, which is actually related to the injected error.
  • gdalinfo, gdal_translate and QGIS can successfully read test.vrt.
  • The procedure does work as expected if, instead of a SENTINEL2 image, I use LANDSAT8 (i.e. plain GeoTIFF) data.

I am using Ubuntu 14.04 with GDAL-2.1.0 compiled by myself with the flags --with-dods-root=/usr --with-ogdi=no (of course, gdalinfo, gdal_translate and QGIS are also compiled and ran with the same build).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.