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.shpand click Open.
ne_10m_admin_0_countriesas the Input vector layer. The Dissolve field would be
CONTINENT. Name the output file as
continents.shpand check the box next to Add result to convas.
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.
continentlayer added to QGIS. Use the Select Single Feature tool from the toolbar and click on Africa to select the polygon representing the continent.
continentslayer 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.
africalayer loaded in QGIS containing a single polygon for the entire continent. Now, it’s time to start our batch clip process. Open .
Ctrlkey and select all the layers that you want to clip. You may also use
Ctrl-Ato make multiple selection. Click Open.
africa.shpClip 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.