4

I have a huge QGIS (using 2.12.3-Lyon) project with several layers stored in a SQL database. Now I need these layers as Esri shapefiles. It is possible to right click one of the layers, click on "Save as..." and save it to SHP. The resulting shapefile can be used in ArcMap without any issues.

How can I do that for all my layers without handling each one manually?

I already marked all my layers and right clicked them to use the "Save as..." option which leads to one big SHP file but I need the files separately.

2 Answers 2

5

There is an extension called "Batch save vector Layers". With this tool, you can save multiple files as ESRI Shapefiles in a user defined destination folder. Note that the extension is marked as experimental, but everything works fine for me so far.

0

Haven't tested this with an SQL database but you could use the following code in the Python Console to export loaded layers as shapefiles:

results_path = "C:/Users/You/Desktop/Folder_Name//"
layers = QgsMapLayerRegistry.instance().mapLayers().values() 
for layer in layers:
    QgsVectorFileWriter.writeAsVectorFormat(layer, results_path + layer.name(),"utf-8",None,"ESRI Shapefile")

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.