QGIS Multilayer clipping

Robert Crowther May 2025

I often find mself wanting to clip from larger size maps. Only a rectangle, an even rectangle. As a new set of map data, not a reference. Into a Geopackage. On many layers (maybe seventeen). I’ve found no easy way to do this.

A guide layer

Whatever way you do this, likely a layer with a shape in it is needed to cut the map to. So create a new layer,

Layer > create make a new Geopackage Layer

Make,

Geometry = Polygon

and don’t overwrite if it exists!

Check the CRS. Especially if using a source clip layer to clip to edges. And yes, a few times I’ve gone wrong on this, found polygons disappearing when I came to edit them.

This step is a trail. I can never see enough to find the size of shape needed. Toggle ‘layer editing’. Draw a small rough four sided shape, anywhere. SHIFT‐RIGHT CLICK to finish.

Now click and drag until at least one vertex is in a position where you’d like it, such as marking an outside edge. Don’t bother making this polygon square, that’s the next step. Just mark with a vertex where you’d like a top or side line of the clip to be.

Editing to a perfect rectangle

Make sure you’re editing, and select the vertex edit tool. Now, if you right click on the polygon‐thing, the list of attribute coordinates will display as a panel (this is much easier than manipulating the full attribute table).

Now cut and paste your selected X and Y values from the vertex that you set as good to the other vertex. Sometimes this will go wrong, or QGIS will loose track, and a vertex will fly out to the side. But, while doing this, QGIS can keep an undo list so, if that happens, you can undo.

Cipping to source map edges

Fairly often I need a rectangle clip to line up with one or more source map edges. Course, other visual editors have snap‐to‐canvas type ability, but QGIS doesn’t.

For this, you’ll need a clip layer for the source map, too. If you havn’t got one, you could make one. Or try snapping to features on another layer, but that’s a whole load of extra grief—which features reach to which edges?

When you make your polygon, again don’t try to get vertexes onto a map edge. Set one or two roughly. But if you can, it may help to put edge‐snapping vertex close because it stops them jumping about so much.

When you have your rough polygon, switch to the outside polygon layer (assuming you have one), make that visible, editable then right‐click to get the attribute table. Copy the accurate X and Y coordinates from there instead.

QGIS, in any of my versions can get in a muddle over this. I get frequent computer seizures. Need to restart QGIS, or even reboot the computer. It can take me twenty or thirty minutes to get a layer set up, a clipping polygon positioned, and the polygon shaped to a rectangle.

The plugin

It’ll help. It’s called ClipMultipleLayer, and it’s in the repository. Install it.

The plugin clips all visible layers into Shapefiles (or raster fragments) contained in folders. So you’ll need to make a place for these (the plugin offers a temp files option, but in a process of this length and risk I prefer to handle my temporary files myself).

Run, and all the new layers will be clipped into the folder specified, and also loaded into the current project.

image of qgis_plugin_clipmultiplelayers
Neat, if temp

Packaging

Toolbox > Database > Package Layers

Set ‘input layers’ as all the new clipped layers (in my case, many). No need to put in the clipping layer, as I think Package Layers will insert into the existing Geopackage if possible, so the clip layer is already there. Also, attempting to insert an new layer of the same name will cause Package Layers to bail.

Switch to the Parameters panel, set a new Geopackage, run.

image of qgis_package_layers
Geopackaging Layers

Tidy

You’re feeling bold, yes? The packaging ran without failure?

Close the project without saving. This will dispose of all the layers written out by multilayer clipping.

Reopen the project. Highlight all the original layers in the the project and delete them (SHIFT‐CLICK, menu, whatever).

Blank project. Scarey. And you won’t get an undo on these actions either.

Open a browser, find the new, clipped‐layer Geopackage then drop it on the QGIS ‘Layers’ panel. Say ‘Ok’ to importing all the layers.

If you’re like me, you’ll want to save the project immediately. Then confirm the imported layers are lodged in a Geopackage sited where I want (I’m paranoid).

Post clipping damage

The clipping and packaging will prepend namespacing tags to layer names, which creates brain‐frying long names. I don’t bother doing much about this.

You could run this process trying to preserve styles. I’ve not experimented, I just know I’ll need to reapply styles.

Comments

I sure wish there was a plugin could make a rectangle of a polygon (inner or outer). Sounds like a small thing, but I have great difficulty locating clip‐polygons—‐rectangling them is extra trouble.

The plugin saves me making a multilayer clipping expression. That’s a huge timesaver. The ‘clip from visible layers’ action is intuitive and should be default, but a pity the plugin doesn’t offer manual adjustment. Also, everything about the plugin suggests it was a lovely piece of work at the time, shame it can’t insert/create a Geopackage. No, I’m not the one to update it… not now, anyway.