Generate a Survey Grid of Equal-Sized Cells in QGIS

QGIStutorialsurvey gridGISPython

Survey grids are used for systematic sampling, trial plot layouts, inspection zones, and report maps. Generating one manually in QGIS is straightforward but repetitive. This script does it in one run with automatic CRS handling.

What it does

The grid_generation.py script creates a regular rectangular grid of equal-sized cells in metres. If polygon GeoJSON layers are checked (visible), the grid is clipped to their combined shape — only cells that fall inside the polygons are kept. If no polygon layers are visible, the grid covers the current canvas extent.

The script automatically detects geographic CRS (latitude/longitude in degrees) and reprojects to the appropriate UTM zone so the cell size you set is in real metres, not degrees.

Output: grid_clipped.geojson saved in the same directory as the first checked polygon layer, loaded into the QGIS project.

What you need

  • QGIS 3.28 or newer
  • numpy, QGIS processing framework (both bundled with QGIS)
  • (Optional) polygon GeoJSON layers checked in the Layers panel to clip the grid
  • The grid_generation.py script from the GIS Utilities Pack

Steps

  1. Load your boundary polygon layer into QGIS and check (tick) it in the Layers panel.
  2. Open Plugins → Python Console → Show Editor.
  3. Paste the script. At the bottom, set:
    • cell_size_m — the width and height of each grid cell in metres (e.g. 50 for a 50×50 m grid)
  4. Click Run.

If no polygon layer is visible, the grid covers the current canvas extent — useful for creating a reference grid without a specific boundary.

Configurable parameters

ParameterWhat it controls
cell_size_mWidth and height of each cell in metres

Common uses

  • Sample plot grids — divide an estate into equal-area cells for systematic soil or crop sampling
  • Inspection zones — create reference cells for aerial survey coverage planning
  • Report maps — overlay a scale grid on a map layout for reference

Get the script

grid_generation.py is part of the GIS Utilities Pack — four everyday QGIS automation scripts for $25 USD.