1

Does anybody knows how to write several QGIS layers on a same spatialite file using QgsVectorFileWriter or another way to add several same layers type to a Spatiallite specific table using QgsVectorFileWriter?

I tried this

lyrList = [layer for layer in QgsMapLayerRegistry.instance().mapLayers().values()]

crs = QgsCoordinateReferenceSystem('EPSG:22181')

for lyr in lyrList:
   QgsVectorFileWriter.writeAsVectorFormat(lyr, 'p1.sqlite',"utf-8", crs, "SQLite", False, None ,["SPATIALITE=YES"])

But it only write the last layer in the same db.

I am not sure where specify the destination table name or specify I want to add new data to same table.

  • QgsVectorFileWriter seems to be a simpler method to transfer several layers to a layer because it get the project crs and not each layer's crs. By this way it seems that there are no necessity to detect the input layer crs. Can anybody confirm this? – Gabriel Asato Feb 1 at 16:52

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.