1

I have multiple QGIS maps with a KML vector layer and a delimited text layer on top (csv file). I want to save these maps as images using a script as follows in the python console to do this.

for project_name in projects:
    QgsProject.instance().setFileName(project_name + '.qgs')
    QgsProject.instance().read()
    # Save content of map canvas as image
    qgis.utils.iface.mapCanvas().saveAsImage(project_name + '.png')

However, the projects are not being read with the error regarding the delimited text layer which is:

File cannot be opened or delimiter parameters are not valid.

This is not the case when I open the project manually in the QGIS UI. The projects loads correctly and also gets saved as an image.

Edit: I upgraded from QGIS 2.8 to 2.18 and now it throws a dialog box which is a 'Handle Bad layers' one. I don't understand why that is when all the file paths are correct and the project opens normally outside the console.

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.