Warning
A new version of this tutorial is available at Batch Processing using Processing Framework (QGIS3)
QGIS 2.0 introduced a new concept called Processing Framework. Previously known as Sextante, the Processing Framework provides an environment within QGIS to run native and third-party algorithms for processing data. It contains a nice batch processing interface that allows one to execute an algorithm on several layers easily. Batch processing is a useful tool that can save manual effort and help you automate repetitive tasks.
We will take several global vector layers and clip them to the extent of Africa in a single batch command.
Natural Earth has several global vector layers. Download the following layers
Once downloaded, unzip and extract all the shapefiles in a single folder.
Data Source: [NATURALEARTH]
ne_10m_admin_0_countries.shp
and click Open.ne_10m_admin_0_countries
as the Input vector layer.
The Dissolve field would be CONTINENT
. Name the output file
as continents.shp
and check the box next to Add result to
convas.Note
If you want to merge ALL polygons regardless of their attributes, you can select – Dissolve All – as the Dissolve field. This will combine all polygons in the layer and give you a single aggregate polygon.
continent
layer added to QGIS. Use the
Select Single Feature tool from the toolbar and click on Africa
to select the polygon representing the continent.continents
layer and select Save Selection
As….africa.shp
. Since we are only interested in the
shape of the continent and not any attributes, you may check the
Skip attribute creation. Make sure the Add saved file
to map box is checked and click OK.africa
layer loaded in QGIS containing a single
polygon for the entire continent. Now, it’s time to start our batch clip
process. Open .Ctrl
key and select all the layers that
you want to clip. You may also use Shift
or Ctrl-A
to make
multiple selection. Click Open.africa.shp
Clip layer. Since the clip layer is the same for all our inputs,
you can double-click the column header Clip layer and the same
layer will be auto-filled for all the rows. Next, we need to define our
outputs. Click the … buton next to the first row in the
Clipped column.clipped_
and click Save.output_
filename. This is important to ensure all the output files have
unique names and they do not overwrite each other.This work is licensed under a Creative Commons Attribution 4.0 International License