I'm trying to copy a shapefile and give it a new name in QGIS python console, I am trying to use the QgsVectorFileWriter class' writeAsVectorFormat method

    QgsVectorFileWriter.writeAsVectorFormat(QgsVectorLayer, QString, 
    QString, QgsCoordinateReferenceSystem, QString driverName="ESRI
    Shapefile", bool onlySelected=False, QString errorMessage=None,
    QStringList datasourceOptions=QStringList(), QStringList 
    layerOptions=QStringList(), bool skipAttributeCreation=False, 
    QString newFilename=None, QgsVectorFileWriter.SymbologyExport 
    symbologyExport=QgsVectorFileWriter.NoSymbology, float 
    symbologyScale=1, QgsRectangle filterExtent=None) -> 

I am unable to determine what the QString arguments (arguments 2 & 3) are supposed to be..I get that they are strings, but strings of what?? Is there a resource I could go to that would give more help than this? I am just trying to take a shapefile, copy it and give it a new name, is this the best way?


1 Answer 1


Your best bet are the API docs, in this case http://www.qgis.org/api/classQgsVectorFileWriter.html#ac25d02c9ad8bfe6113ba7a06a981a447 and the PyQGIS Cookbook.

  • @rickdebbout - Don't forget to accept answers which have solved your problems by clicking the green faded tick on the left-hand side =)
    – Joseph
    Mar 29, 2016 at 14:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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