I'm looking for a solution how to use the OGR/GDAL configure options (--config) in the QGIS Python environment. http://trac.osgeo.org/gdal/wiki/ConfigOptions

Setting special configure options is necessary to load some data correctly (OGR Driver).

QgsVectorLayer(filename, title, "ogr") 

One usually sets options in C with CPLSetConfigOption. In python it would be gdal.SetConfigOption(option, value), e.g., gdal.SetConfigOption('PG_USE_COPY', 'YES')


In the C and C++ API you can use

CPLSetConfigOption("GDAL_DATA", "your folder path with gdal-data");

In Qt I use

CPLSetConfigOption("GDAL_DATA", QDir( QCoreApplication::applicationDirPath().append("/gdal-data")).absolutePath().toLocal8Bit() );

As my gdal-data folder is relative to the executable path.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.