I am using QGIS 3.10.2-A Coruña. I have a UK County Boundaries shapefile layer and a custom Grid (gpkg) layer with a fixed distance of 1.5 miles between intersections in both planes (eastings & northings).

I need to:

  1. select one county at a time;
  2. select squares in the grid which partly or wholly overlay that county, to create a new layer.

Is this even possible?

4 Answers 4


There are several possibilities to achieve this - this is a rather straight forward one, with probably a lot of manual work.

Run join attributes by location: Your first layer is the grid, your second layer your Counties. Either attach all attributes of the Counties to the grid, or choose only their name. Make sure to set one to many as your join-type.

Then use select by attribute on the modified grid and go through each County name - save the selection to a new file, then select the next name.

This probably could be done faster using Python or maybe SQL.


This can be done quite simply and easily using one of QGIS's built-in tools, Extract By Location. Not only does this tool subset your input layer by its spatial relationship to another layer, but it can do so on a per-county basis.

If I've understood the process in your question, proceed as follows.

  1. Open the Extract By Location tool.
  2. Specify your_grid_layer under Extract features from.
  3. For the geometric predicate, Intersect should be selected by default, and should work well enough, but you can change this as needed.
  4. Specify your_counties_layer under By comparing the features from.
  5. Most importantly! Click the green circular arrows to iterate over the counties layer. This will create a separate extracted output for every county feature.
  6. Run the tool.

Input layers and tool: input layers and tool parameters

Output layers: output layers

Note that each color represented in the image above is a separate layer, I've simply chosen to match their colors to the input features. And in each, the layer corresponds to the cells of the input grid which intersected a single county feature.

Also! Because many grid cells intersected more than one polygon, there is considerable overlap among these output layers. With only two of them on, this is more apparent.

subset of output

  • Definitely the easier and faster option compared to mine.
    – Erik
    Commented Jul 13, 2020 at 8:34
  • Thank you so much. This is such a useful step for me on my vertical learning curve! I'm looking to clip the universal grid to those cells lying within a given county boundary. To label them sequentially from 1 to n. Then to extract the features from other layers in the project which fall within any one cell. I don't know if I'm being unrealistic or just dense. Thank you again for your help. Invaluable. Commented Jul 13, 2020 at 10:27
  • That all seems doable, but of course would warrant its own question on this site should you run into trouble. I think, though, that the Extract By Location tool will be useful in extracting features from your other layers as well. Depending on the number of layers and counties you're dealing with, it may be worth your time to learn a bit about using the graphical modeler, to chain a series of processes together.
    – jcarlson
    Commented Jul 13, 2020 at 12:17
  • Thank you! Good advice about the graphical modeler. Commented Jul 14, 2020 at 10:49
  • One final note. I don't know what your plan is with the data, and this comes with its own learning curve, but look into Q's Reports. It's sort of like an Atlas, but one that can be recursive, in a way. You could define a group based on the counties, then for each, have a map series, etc, generated for each intersecting grid cell, and for each of those, have something else happen (attribute table, symbology, etc) for features which intersect it.
    – jcarlson
    Commented Jul 14, 2020 at 11:19

So it turns out to be quite straightforward. I don't profess it's a panacea but it seems to work for the project in question. Sincere apologies for the non-technical layout below but they're hopefully a useful set of instructions.

Please post any questions. Huge thanks again to the original respondents.


The following operations are all accessed through the Processing Toolbox panel:

Step 1: Isolate county boundary to work on: County Boundaries - Attribute Table - Select - Invert Selection - Delete

Step 2: Build vector grid: Vector Creation - Set Grid - Polygon – Enter bespoke Extents and Spacings

Step 3: Extract Grid Squares that intersect with county boundary: Vector Selection - Extract by Location - Extract from GRID (from Step 2) by COUNTY (from Step 1)

Step 4: Clip Grid Squares to County Boundary: Vector Overlay - Clip - Input: EXTRACTED BY LOCATION (from Step 3), Overlay: COUNTY (from Step 1)

Step 5: Prepare Clipped layer for labelling individual cells – Stage 1: Vector Table - Add ‘autoincremental’ field - Input: CLIPPED (from Step 4), Field Name=AUTO, Start Values=1

Step 6: Prepare Clipped layer for labelling individual cells – Stage 2: Vector Geometry - Centroids - Input: INCREMENTED (from Step 5)

Step 7: Sequential labelling of individual cells: Layer Properties of CENTROIDS (from Step 6) - Single Label – AUTO (see Step 5) - Placement: Around Point

Step 8: Select features from within individual cells: Vector Overlay – Intersection – Input: features layer (from your project), Overlay: CLIPPED LAYER (from Step 7) – Open Attribute Table for newly created layer - Sort Results by AUTO column (or any mode of analysis you choose).

E & O E


If you just want to make a selection, you could also use Select by location.

  1. Go to menu Vector > Research tools > Select by Location.
  2. Select your grid layer as input and check one of the geometric predicates (I used intersect). By comparing to the features from: chose your boundaries shapefile layer (where you made your original selection). Check the Use selected features only checkbox and be sure to define Modify current selection by creating a new selection.

That's all. See screenshots:

Select by location: input dialogue

Selection on the original layer

Selected grid-cells after running the algorithm

  • Thank you so much. Really appreciate the advice given. Commented Jul 14, 2020 at 10:50

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.