Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
podcast
Filter by Categories
ArcGIS Pro
GDAL
GeoJson
Map
Python
QGIS
Uncategorized

Exporting multiple layers from QGIS

3 ways of exporting multiple layers in QGIS

Exporting multiple layers at once in QGIS can significantly streamline your workflow, especially when working with large projects. As of my last update in April 2023, QGIS does not have a built-in feature to export multiple layers simultaneously through the standard layer export options. However, you can accomplish this task using a few different methods, such as batch processing, using the “Save As Layer File…” option for vector layers, or scripting. Below, I’ll outline a couple of methods to export multiple layers at once, focusing on vector layers.

Working with QGIS? you should be listening to our podcast!

Method 1: Using the “Batch Save Layers” Plugin

One of the easiest ways to export multiple layers at once is by using the “Batch Save Layers” plugin. This plugin allows you to export multiple layers into different formats with various options.

  1. Install the Plugin:
  • Go to Plugins > Manage and Install Plugins...
  • Search for “Batch Save Layers” and install it.
  1. Using the Plugin:
  • After installation, you can access the plugin under Plugins > Batch Save Layers > Batch Save Layers.
  • In the plugin window, you can add the layers you want to export, specify the output format, and set other options such as CRS, file name, and directory.
  1. Export:
  • Configure all the settings according to your needs.
  • Click Run to export all the selected layers.

Method 2: Using the Processing Toolbox for Batch Export

For vector layers, you can use the built-in Processing Toolbox to perform a batch export.

  1. Open the Processing Toolbox:
  • You can access it by clicking on the toolbox icon or by going to Processing > Toolbox.
  1. Find the Export Tool:
  • For vector layers, search for an export tool like “Export to Vector File” or similar. The exact name might vary depending on your QGIS version.
  1. Batch Process:
  • Right-click on the tool and select Execute as Batch Process.
  • In the batch processing window, you can add multiple layers by clicking the Add Row button and configuring the export parameters for each layer.
  1. Configure and Run:
  • Set the output path and any other necessary parameters for each layer.
  • Click Run to start the batch export process.

Method 3: Using Python Scripting

For more advanced users, Python scripting within QGIS allows for highly customizable export processes. You can write a script to iterate through your layers and export them using your specified parameters.

  1. Open the Python Console in QGIS:
  • Go to Plugins > Python Console.
  1. Write a Script:
  • You can use the QgsProject.instance().mapLayers() method to get all layers and then loop through them, using the QgsVectorFileWriter.writeAsVectorFormat() function to export each one.
  1. Execute the Script:
  • Run your script in the Python Console to export the layers.

Each of these methods offers a way to export multiple layers at once in QGIS, with varying degrees of flexibility and complexity. Choose the one that best fits your needs and skill level.

Here are some frequently asked questions on this topic:

Can I export both raster and vector layers at the same time in QGIS?

QGIS does not offer a built-in, direct feature specifically designed for exporting both raster and vector layers simultaneously with a single command or action through the GUI (Graphical User Interface).

The export processes for raster and vector data in QGIS are typically distinct due to the different nature of these data types and the options available for exporting them. However, there are workarounds and methods to efficiently handle the export of both types of layers, albeit not “at the same time” in the strictest sense but in a streamlined manner.

Workarounds and Methods

  1. Batch Processing with Python Scripting: The most flexible way to export both raster and vector layers at the same time is by using Python scripting within QGIS. You can write a script that iterates through your layers, checks whether each layer is raster or vector, and then exports it using the appropriate method. This requires some familiarity with PyQGIS, the Python library for QGIS.
  2. Using Plugins: While there isn’t a specific plugin that targets the simultaneous export of raster and vector layers as of my last update, plugins like “Batch Save Layers” are designed for vector layers and can streamline part of the process. You might find or develop custom scripts or plugins that extend QGIS functionality to better suit your needs for batch processing both types of data.
  3. Sequential Batch Processing: You can perform batch processing for vector and raster layers separately but efficiently one after the other. For vector layers, tools like “Export to Vector File” can be used in batch mode through the Processing Toolbox. For raster layers, you can use tools like “Translate (Convert Format)” in a similar batch mode. This approach doesn’t export them “at the same time” but can be set up to run one after the other.
  4. Automation Outside QGIS: Depending on your workflow, it might be practical to use external scripts (e.g., using Python with GDAL/OGR outside of QGIS) to handle the export of both raster and vector data based on the output from a QGIS project. This approach requires a good understanding of GIS data manipulation and scripting but offers high flexibility and can be integrated into larger data processing pipelines.

Maintaining Layer Styles When Exporting

When exporting layers, especially vector layers, from QGIS, you might want to preserve the styling (colors, symbols, line widths, etc.) that you’ve applied within QGIS. The ability to maintain these styles depends on the format you’re exporting to and the method used for export.

  1. Exporting to GeoPackage or Shapefile: For vector layers, styles can be saved within a GeoPackage or alongside a shapefile in a .qml file. When exporting, you can save the layer style directly into the GeoPackage, or save the style as a .qml file for shapefiles, which can then be imported into QGIS later or shared with other users.
    • To save a style to a GeoPackage, right-click the layer > Export > Save Features As..., choose GeoPackage as the format, and in the dialog, check the option to save the layer style into the database.
    • To save a shapefile’s style, right-click the layer, choose Properties > Symbology, and at the bottom, you’ll find options to Save Style.... Choose QGIS Layer Style File (*.qml) to save the style separately.
  2. Exporting to PDF or SVG: If you’re looking to export maps with their styles for presentation or publication purposes, you can use the Print Layout feature to design your map and then export it to PDF or SVG. This way, the styles, as they appear in your layout, are preserved.

Batch Exporting Layers with Different CRS

When you need to export multiple layers that may have different CRS settings, you can handle this efficiently in QGIS, ensuring that each layer is exported with the correct CRS. Here’s a general approach using batch processing:

  1. Prepare Your Layers: Ensure that each layer is set with its correct source CRS in the layer properties. QGIS can handle layers with different CRSs on-the-fly, reprojecting them as needed for display purposes.
  2. Batch Export Using Processing Toolbox:
    • For vector layers, you can use tools like Export to Vector File found in the Processing Toolbox. Access the tool, then right-click and choose Execute as Batch Process.
    • In the batch processing dialog, you can add multiple layers to the list. For each layer, you can specify the output file format and destination, and importantly, set the CRS for the output. Here, you can choose to use the layer’s source CRS, a project CRS, or a specific CRS you need the output in.
  3. Using Python for Advanced Control: If you’re comfortable with scripting, you can use Python (PyQGIS) to automate the export process, giving you full control over handling different CRSs. You can script the export process to check each layer’s CRS and apply any necessary transformations or ensure they’re exported with their original CRS.
  4. CRS Considerations: When exporting layers, especially for use in other projects or software, it’s crucial to be mindful of the CRS. Consistency in CRS ensures spatial accuracy and compatibility. If you’re combining layers in a single project or for a specific analysis, you might need to standardize the CRS across all layers.

About the Author
I'm Daniel O'Donohue, the voice and creator behind The MapScaping Podcast ( A podcast for the geospatial community ). With a professional background as a geospatial specialist, I've spent years harnessing the power of spatial to unravel the complexities of our world, one layer at a time.