---
title: "Groundwater monitoring from AGS4: hydrographs, groundwater level maps and the QGIS Temporal Controller"
description: "Read standpipe dips from AGS4 (MONG, MOND), flag dry pipes, draw hydrographs by unit, contour the groundwater level and animate the readings in QGIS."
url: https://www.technicalgis.com/tutorials/groundwater-monitoring-ags4-python-qgis/
author: Sean Blaney (https://www.technicalgis.com/about/#sean-blaney)
publisher: TechnicalGIS (https://www.technicalgis.com/about/)
published: 2026-12-03
updated: 2026-12-03
language: en-GB
---

# Groundwater monitoring from AGS4: hydrographs, groundwater level maps and the QGIS Temporal Controller

> Read standpipe dips from AGS4 (MONG, MOND), flag dry pipes, draw hydrographs by unit, contour the groundwater level and animate the readings in QGIS.

- Level: Intermediate
- Tested with: Python 3.12
- Source code: [Download scripts](https://www.technicalgis.com/code/groundwater-monitoring-ags4-python-qgis/)

Series · Part 9 of 13

## [AGS data in GIS](https://www.technicalgis.com/tutorials/series/ags-data-in-gis/)

1.  [Read and validate AGS4 ground investigation data with Python](https://www.technicalgis.com/tutorials/read-validate-ags4-python/)
2.  [Boreholes on a map: AGS4 locations in British National Grid with QGIS](https://www.technicalgis.com/tutorials/ags4-boreholes-map-qgis/)
3.  [3D borehole logs from AGS4 data in PyVista and QGIS](https://www.technicalgis.com/tutorials/3d-borehole-logs-pyvista-qgis/)
4.  [A geological cross-section from AGS4 boreholes and LIDAR in Python and QGIS](https://www.technicalgis.com/tutorials/geological-cross-section-ags4-python/)
5.  [A 3D ground model from AGS4 boreholes: kriged stratum surfaces in Python](https://www.technicalgis.com/tutorials/geological-ground-model-surfaces-python/)
6.  [Visualising SPT N-values from AGS4 data in Python](https://www.technicalgis.com/tutorials/spt-n-values-ags-python/)
7.  [3D-print a geological ground model: one watertight STL per stratum](https://www.technicalgis.com/tutorials/3d-print-geological-ground-model/)
8.  [Laboratory classification data from AGS4: plasticity charts, grading curves and maps in Python](https://www.technicalgis.com/tutorials/ags-laboratory-classification-python/)
9.  Groundwater monitoring from AGS4: hydrographs, groundwater level maps and the QGIS Temporal Controller

Part 10 is out 10 December 2026. [See the whole series](https://www.technicalgis.com/tutorials/series/ags-data-in-gis/)

## Key takeaways

1.  Groundwater monitoring lives in two AGS4 groups: MONG describes each installation, with its response zone, and MOND holds every reading, one row per measurement, with its type in MOND\_TYPE. Water level dips are the WDEP rows.
2.  Not every WDEP row is a dip. In the A417 file 10,893 of the 13,339 are the depths of water quality sonde readings, and 681 dips have no reading at all, so filter on the remarks and count what you drop.
3.  A dip at the base of the pipe means the pipe was dry, not that the water was at that depth. Flagging those 29 readings, and three readings far out of step with their neighbours, keeps the statistics honest.
4.  Grouped by the unit each response zone is in, the hydrographs show the same seasonal swing everywhere, lowest in September 2020 and highest in the winter of 2020/21, and the Birdlip Limestone contours show a groundwater divide, with water draining to the escarpment and down dip to the south-east.

## Before you start

-   Part 1 of this series, or at least its helper module a417\_ags.py
-   Python 3.10+ with python-ags4, pandas, GeoPandas, rasterio, requests and matplotlib
-   QGIS 3.40 LTR for the Temporal Controller project (Part 2 shows how to run PyQGIS scripts)

**A borehole log tells you where water was struck on the day it was drilled. A standpipe tells you where the water sits, month after month.** In Part 8 we read the laboratory tests from the A417 Missing Link investigation. The same AGS4 file holds two and a half years of groundwater monitoring on Crickley Hill, and this part turns it into hydrographs, maps and an animated QGIS project.

There are 68 installations and 103,309 readings. By the end you will know which of those readings are water levels, which pipes were dry, which unit each pipe is measuring, how the water rose and fell from 2019 to 2021, and where it sits in the limestone under the escarpment.

The steps are:

1.  read the monitoring groups, MONG and MOND;
2.  separate the water level dips from everything else and flag dry pipes;
3.  find the response zone of each pipe and the unit it is in;
4.  draw hydrographs for each unit;
5.  map the depth to groundwater and contour the groundwater level in the limestone;
6.  write the standpipes, readings and contours to a GeoPackage;
7.  animate the readings with the QGIS Temporal Controller.

The code is [`groundwater_monitoring.py`](https://www.technicalgis.com/code/groundwater-monitoring-ags4-python-qgis/) and `qgis_groundwater.py` for the QGIS project. Like Part 8, it uses `a417_ags.py` from Part 1 for the repaired borehole locations and geology.

![Two QGIS map frames of Crickley Hill side by side on a grey LIDAR hillshade, September 2020 on the left with 31 readings and February 2021 on the right with 43. Every standpipe is an open circle, and each pipe dipped that month is filled by how far its water level is from the pipe's own median. In September most filled circles are orange, 0.5 to 2 m below, with three dark brown more than 2 m below; in February they are light and dark blue, above the median. Dark blue lines labelled 198 to 216 are the groundwater contours in the Birdlip Limestone.](https://www.technicalgis.com/_astro/05-qgis-temporal-frames.BJUrh9fx_Z2cobsj.webp)

_Two frames from the QGIS Temporal Controller: the dips made in September 2020 and February 2021, each coloured by the change from that pipe's own median level._

## Step 1: read the monitoring groups

The monitoring data is only in the file the contractor deposited with the BGS, the same one Part 8 downloaded. If you ran Part 8, the script finds it in `data/` and skips the download.

`groundwater_monitoring.py`

```python
path = fetch(f"{ACCESSIONS}/download/{A.ITEM}?fileName={quote(ORIGINAL)}", DATA / ORIGINAL)
tables, headings = AGS4.AGS4_to_dataframe(str(path))
mon = A.numeric({g: tables[g] for g in ["MONG", "MOND"]})
mong, mond = mon["MONG"], mon["MOND"]
mond["MOND_RDNG"] = pd.to_numeric(mond.MOND_RDNG.astype(str).str.strip(), errors="coerce")   # typed XN
mond["time"] = pd.to_datetime(mond.MOND_DTIM, errors="coerce")
print(f"MONG: {len(mong)} installations in {mong.LOCA_ID.nunique()} holes; types: "
      + ", ".join(f"{t or '(blank)'} {n}" for t, n in mong.MONG_TYPE.value_counts().items()))
print(f"MOND: {len(mond):,} readings from {mond.time.min():%d %b %Y} to {mond.time.max():%d %b %Y}")
kinds = mond.groupby(["MOND_TYPE", "MOND_UNIT"]).size().rename("rows").reset_index()
print(kinds.to_string(index=False))
```

`Output`

```text
=== Step 1: the monitoring installations and readings ===
MONG: 68 installations in 62 holes; types: SP 56, ICM 7, (blank) 3, SPIE 2
MOND: 103,309 readings from 31 Jan 2019 to 20 Oct 2021
MOND_TYPE MOND_UNIT  rows
     DBSE         -     3
     DBSE         m  2140
       DO      mg/l  8750
       EC     uS/cm 11343
       PH         - 11144
      RDX        mV 11343
      RES     ohmcm 11342
      SAL       PSU 11218
 SAMPTEMP      degC 11344
      TDS       ppm 11343
     WDEP         -     4
     WDEP         m 13335
```

`MONG` has one row per installation: 56 standpipes (`SP`), two standpipe piezometers (`SPIE`), three with no type, and seven inclinometers (`ICM`), which measure ground movement rather than water. `MOND` has one row per measurement, and the table of `MOND_TYPE` shows what most of them are: dissolved oxygen, conductivity, pH, redox, resistivity, salinity, temperature and dissolved solids from a water quality sonde. The water levels are the `WDEP` rows, and `DBSE` is the measured depth to the base of the pipe.

## Step 2: separate the water level dips and flag dry pipes

Two things hide inside the `WDEP` rows. When the sonde was lowered down a pipe, each of its readings was logged with the depth it was taken at, as a `WDEP` row with the remark “Water quality monitoring level”. And some visits recorded no reading at all. We drop both, after counting them:

`groundwater_monitoring.py`

```python
wdep = mond[mond.MOND_TYPE.eq("WDEP")]
quality = wdep.MOND_REM.eq("Water quality monitoring level")
dips = wdep[~quality].copy()
base = (mond[mond.MOND_TYPE.eq("DBSE")].groupby(PIPE + ["MOND_DTIM"], dropna=False).MOND_RDNG.first()
        .rename("base"))
dips = dips.join(base, on=PIPE + ["MOND_DTIM"])
dips["base"] = dips.base.fillna(dips.MONG_DIS)          # measured depth to the base of the pipe, else as installed
blank = dips[dips.MOND_RDNG.isna()]
dips = dips[dips.MOND_RDNG.notna()].rename(columns={"MOND_RDNG": "depth"})
dips["dry"] = dips.depth >= dips.base - DRY_TOL
dips = dips.join(loca[["LOCA_NATE", "LOCA_NATN", "LOCA_GL"]], on="LOCA_ID")
dips["level"] = dips.LOCA_GL - dips.depth
```

A dip meter lowered into a dry pipe stops at the bottom, so a “depth to water” equal to the depth of the pipe means there was no water. `DRY_TOL` is 5 cm: any dip within 5 cm of the base measured on the same visit, or of the installed depth when the base was not measured, is flagged as dry. The level in metres above Ordnance Datum is the repaired ground level from Part 1 minus the depth.

Then we look for readings far out of step with the ones either side. A single dip more than 3 m away from both its neighbours, in the same direction, is more likely a misread tape or a typing slip than a real change in the groundwater:

`groundwater_monitoring.py`

```python
dips = dips.sort_values(PIPE + ["time"])
step = dips.groupby(PIPE, dropna=False)["level"]
before, after = dips.level - step.shift(1), dips.level - step.shift(-1)
dips["spike"] = ~dips.dry & (before.abs() > SPIKE) & (after.abs() > SPIKE) & (np.sign(before) == np.sign(after))
wet = dips[~dips.dry & ~dips.spike]
```

`Output`

```text
=== Step 2: separate the water level dips and flag dry pipes ===
WDEP rows: 13,339; 10,893 are the depths of water quality readings, in 24 holes
2,446 dips; 681 with no reading. Remarks on those: '(none)' 665, '19mm standpipe' 4, 'Turf has possibly regrown over the cover.' 3, 'Unable to monitor due to access constraints' 3, '19mm piezometer' 3, 'Unable to monitor - vehicle parked on position.' 1, '50mm standpipe' 1, 'Fly tipped over (mattress and timber).' 1
1,765 readings in 57 pipes, Jan 2019 to Jul 2021; 29 dry
dry readings by pipe: DSRC310 G1 1, DSRC314 G1 2, DSRC401 G1 1, DSRC404 G1 2, DSRC420 G1 2, OH407 G1 21
out of step with the readings either side (kept, but left out of the statistics): DSRC224 23 Oct 2019 (-6.7 m), DSRCOH304 16 Jun 2021 (-8.5 m), OH417 18 Dec 2020 (+8.8 m)
```

Of 13,339 `WDEP` rows, only 2,446 are dips, and 681 of those are blank. The remarks explain a few: a 19 mm pipe too narrow for the dip meter, a cover lost under turf, a parked van, a fly-tipped mattress. That leaves 1,765 readings in 57 pipes. Twenty-one of the 29 dry readings are in OH407, and DSRC310, dipped 27 times, gave a reading only once, at 30.05 m in a 30 m pipe: dry. So 56 pipes have a water level.

## Step 3: find what each pipe is measuring

A water level only means something once you know which ground it comes from. A standpipe reads the groundwater in its response zone, so we take the unit at the middle of each zone from `GEOL`, using the same interval join as Parts 6 and 8. One pipe, DSRC229, has its response zone entered upside down, with the top deeper than the base, so we swap those first:

`groundwater_monitoring.py`

```python
pipes = mong[~mong.MONG_TYPE.eq("ICM")].copy()             # inclinometers measure movement, not water
swap = pipes.MONG_TRZ > pipes.MONG_BRZ
pipes.loc[swap, ["MONG_TRZ", "MONG_BRZ"]] = pipes.loc[swap, ["MONG_BRZ", "MONG_TRZ"]].values
pipes["mid"] = (pipes.MONG_TRZ + pipes.MONG_BRZ) / 2
m = pipes.reset_index().merge(geol, on="LOCA_ID")
inside = m[(m.GEOL_TOP <= m.mid) & (m.mid < m.GEOL_BASE)].drop_duplicates("index").set_index("index")
pipes["UNIT"] = inside.UNIT.reindex(pipes.index).fillna("NR")
```

The script then works out each pipe’s median depth and level, its range and its number of readings, and flags any pipe where the water only ever sits in the bottom 75 cm of the response zone (`SUMP`). Water there may just be what drained into the sump of the pipe, so the real water table could be lower.

`Output`

```text
=== Step 3: the response zone of each pipe and the unit it is in ===
response zones entered upside down: DSRC229
                       pipes  readings  median_depth  median_level  widest_range
group
Great Oolite Group         7       232           4.7         271.7           8.0
Inferior Oolite Group     18       469          32.6         211.0           7.2
Lias Group                13       464          15.9         172.2          18.6
Other                      4        75          10.3         240.8           7.8
Superficial               14       493           3.8         162.6           3.1
water only ever in the bottom 75 cm of the response zone: DSRC311 G1 (39.3 of 40.0 m), DSRC404 G1 (33.4 of 34.0 m), DSRC314 G1 (14.9 of 15.0 m), OH407 G1 (15.1 of 15.5 m)
```

![Chart of 56 standpipes in five groups along the horizontal axis, with elevation from 110 to 300 m OD on the vertical. For each pipe a black dash marks ground level, a coloured box shows the response zone filled by its geological unit, and a blue triangle with a vertical blue bar shows the median water level and the lowest to highest reading. The landslide pipes on the left are short boxes from 120 to 200 m with water close to ground level. The Lias Group pipes sit between 130 and 270 m. The Inferior Oolite pipes are long orange Birdlip Limestone boxes from 190 to 290 m, with the water near the bottom of each. The Great Oolite and Fuller's Earth pipes are short boxes high up, around 230 to 285 m, with water near the top.](https://www.technicalgis.com/_astro/01-standpipe-response-zones.BcGFluUZ_1RGDPH.webp)

_Every standpipe with a water level: ground level, the response zone coloured by its unit, and the median and range of the water level._

The chart is worth reading pipe by pipe. The landslide deposits at the foot of the escarpment have shallow pipes with water within a few metres of the surface. The Inferior Oolite pipes on the plateau are long, mostly in the Birdlip Limestone, with the water 15 to 80 m down near the bottom of the response zone. The Great Oolite and Fuller’s Earth pipes, highest up the slope, hold water close to ground level, perched on the clays of the Fuller’s Earth.

## Step 4: draw hydrographs for each unit

The pipes span 160 m of elevation, so plotting levels on one axis would squash every seasonal swing flat. Instead each reading is plotted as its change from that pipe’s own median, and the black line is the monthly median of the group. Lines break where a pipe went unmonitored for more than 90 days, so a gap is not drawn as a straight trend:

`groundwater_monitoring.py`

```python
wet = wet.merge(pipes[PIPE + ["pipe", "group", "level_median"]], on=PIPE)
wet["change"] = wet.level - wet.level_median
for ax, grp in zip(axes, shown):
    g = wet[wet.group == grp]
    for pipe, p in g.groupby("pipe"):
        gap = p.time.diff() > pd.Timedelta(days=90)           # break the line where monitoring paused
        p = pd.concat([p, p[gap].assign(time=p.time[gap] - pd.Timedelta(days=1), change=np.nan)]).sort_values("time")
        ax.plot(p.time, p.change, color=GROUPS[grp][1], lw=0.8, alpha=0.55, marker="o", ms=1.6)
    monthly = g.set_index("time").change.resample("MS").median()
    ax.plot(monthly.index + pd.Timedelta(days=14), monthly, color="black", lw=1.8)
```

`Output`

```text
=== Step 4: hydrographs ===
           Superficial: 14 pipes, highest monthly median +0.4 m in Jan 2021, lowest -0.5 m in Sep 2019; median range in a pipe 1.4 m
            Lias Group: 13 pipes, highest monthly median +0.5 m in Apr 2020, lowest -1.1 m in Jan 2019; median range in a pipe 2.0 m
 Inferior Oolite Group: 18 pipes, highest monthly median +0.5 m in Feb 2021, lowest -0.8 m in Sep 2020; median range in a pipe 2.2 m
    Great Oolite Group:  7 pipes, highest monthly median +1.2 m in Mar 2020, lowest -1.6 m in Sep 2020; median range in a pipe 2.0 m
```

![Four stacked hydrograph panels sharing a time axis from January 2019 to July 2021, each with change from the pipe's median from minus 6 to plus 6 m. Thin coloured lines are individual standpipes and a thick black line is the monthly median. Landslide deposits, in brown, stay within about 1.5 m of zero. Lias Group, in blue, has one line falling from above 6 m to 3 m in late 2019 and two out-of-step crosses at the bottom edge. Inferior Oolite, in red, dips in September 2020 and then several lines rise 3 to 5 m in early 2021. Great Oolite, in green, swings most, from plus 1.2 m in March 2020 to minus 1.6 m in September 2020.](https://www.technicalgis.com/_astro/02-groundwater-hydrographs.DU413vP-_1rMJnC.webp)

_Hydrographs for the four main units, each reading plotted as the change from its own pipe's median level, with the monthly median of each group in black._

All four units breathe with the seasons, but by different amounts. The landslide deposits barely move: the median pipe ranges over 1.4 m. The Great Oolite pipes respond most, rising 1.2 m above their medians in March 2020 and falling 1.6 m below by September 2020. September 2020 is the low point in the limestones too, and the winter of 2020/21 the high point: some Inferior Oolite pipes rose about 7 m, and the frames at the top of this page are those two moments.

The widest range, 18.6 m in the Lias Group, belongs to DSRC224. After it was installed in May 2019, its level fell from 217 m to about 205 m by September 2019, then settled near 201.7 m. That is the falling line at the top of the Lias panel. It looks like a pipe slowly equilibrating with low-permeability mudstone after installation, which is worth knowing before reading the first months of any new pipe as the groundwater level.

## Step 5: map the depth to groundwater and the level in the limestone

Every pipe’s median depth to water goes on the LIDAR hillshade from Part 2, with the symbol shape showing the unit and its size the range of levels:

![Map of Crickley Hill on a grey LIDAR hillshade with 10 m contours. Standpipes are drawn with a symbol for each unit, squares for landslide deposits, diamonds for the Lias Group, circles for the Inferior Oolite, triangles for the Great Oolite and crosses for not logged, coloured from yellow for less than 2 m to dark purple for 40 to 90 m to water. Yellow and green squares and diamonds cluster on the lower slopes in the west. Dark blue and purple circles, 20 to 90 m to water, sit along the escarpment edge and on the plateau. Green and teal triangles, 2 to 10 m, are spread across the south-east.](https://www.technicalgis.com/_astro/03-depth-to-groundwater-map.BND4Idsb_Z2x5xw9.webp)

_The median depth to groundwater in each standpipe, by the unit its response zone is in. Bigger symbols mean a wider range of levels._

`Output`

```text
=== Step 5: depth to groundwater and the groundwater level in the limestone ===
           Superficial: depth to water 1.1 to 15.4 m, median 3.8 m
            Lias Group: depth to water 0.3 to 38.0 m, median 15.9 m
 Inferior Oolite Group: depth to water 14.9 to 81.8 m, median 32.6 m
    Great Oolite Group: depth to water 1.8 to 12.8 m, median 4.7 m
                 Other: depth to water 2.2 to 50.6 m, median 10.3 m
```

The depth to water depends far more on the unit than on where you stand. On the lower slopes, in the landslide deposits and Lias, water is a few metres down. In the Inferior Oolite limestones along the escarpment it is 15 to 82 m down. On the plateau to the south-east, the Great Oolite and Fuller’s Earth hold water within 13 m of the surface, well above the limestone’s water table below.

So a single groundwater surface across every pipe would mix separate bodies of water. The Birdlip Limestone is the one unit with enough pipes to contour on its own, 14 of them. We triangulate their median levels, mask the thin sliver triangles at the edge of the network, and contour every 2 m. Three pipes where the water only ever sat in the sump are drawn as open circles and kept out of the surface, because the water table there is somewhere below the bottom of the pipe:

`groundwater_monitoring.py`

```python
lime = pipes[pipes.UNIT.eq("BLPL")]
aq, low = lime[~lime.at_base], lime[lime.at_base]
tri = Triangulation(aq.LOCA_NATE, aq.LOCA_NATN)
tri.set_mask(TriAnalyzer(tri).get_flat_tri_mask(min_circle_ratio=0.05))   # drop sliver triangles at the edges
filled = ax.tricontourf(tri, aq.level_median, levels=levels, cmap="Blues_r", alpha=0.6, zorder=2)
lines = ax.tricontour(tri, aq.level_median, levels=levels, colors="#08306b", linewidths=0.9, zorder=3)
```

`Output`

```text
Birdlip Limestone: 14 pipes contoured, median levels 196.7 to 217.1 m OD; highest DSRCOH414 217.1, DSRC418 215.7, DSRCOH308 215.5
  near the escarpment edge (north of 215,900 N, west of 393,500 E): 8 pipes, 206.8 to 215.7 m OD
  on the plateau to the south-east (south of 215,400 N): 4 pipes, 196.7 to 205.7 m OD
left off the contours, water only in the sump: DSRC311 G1, DSRC404 G1, DSRC314 G1
```

![Map of the Birdlip Limestone standpipes on a grey LIDAR hillshade. A blue triangulated surface runs from a cluster of eight pipes at the escarpment edge in the north-west, through DSRCOH414 at 217.1 m and DSRCOH308 at 215.5 m, south-east to DSRCOH400 at 196.7 m. Dark blue contours every 2 m are labelled 198 to 216. The highest values, 214 to 216, form a ridge across the middle, with contours falling to 208 towards the escarpment cluster and to 198 towards the south-east. Open circles mark DSRC404, DSRC311 and DSRC314, where the water stays in the bottom of the pipe. A box lists the eight escarpment pipes, from 206.8 to 215.7 m.](https://www.technicalgis.com/_astro/04-limestone-groundwater-contours.BSDVHJxV_1ncKE0.webp)

_Groundwater level in the Birdlip Limestone: the median of each standpipe, contoured every 2 m on a triangulation of the pipes._

The levels do not fall steadily in one direction. They are highest in the middle of the network, about 215 to 217 m OD at DSRCOH414, DSRC418 and DSRCOH308, and fall both ways: to 206.8 m among the pipes at the escarpment edge and to 196.7 m on the plateau to the south-east. That is a groundwater divide. North-west of it, water in the limestone drains towards the escarpment and the springs along its face; south-east of it, water drains down the dip of the beds, away from the scarp.

## Step 6: write a GeoPackage for QGIS

Three layers go into one GeoPackage in British National Grid: `standpipes`, one point per pipe with its response zone, unit and statistics; `readings`, one point per dip with its `time`, `depth`, `level`, `change` and the `dry` and `spike` flags; and `limestone_contours`, the 2 m contour lines.

`groundwater_monitoring.py`

```python
readings = dips.merge(pipes[PIPE + ["pipe", "group", "UNIT", "level_median"]], on=PIPE)
readings = readings.assign(group=readings.group.astype(str), change=readings.level - readings.level_median,
                           remark=readings.MOND_REM.fillna(""))
readings = gpd.GeoDataFrame(
    readings[["pipe", "LOCA_ID", "MONG_ID", "time", "depth", "level", "change", "dry", "spike", "group", "UNIT",
              "remark"]],
    geometry=gpd.points_from_xy(readings.LOCA_NATE, readings.LOCA_NATN), crs="EPSG:27700")
segs = [(lvl, LineString(seg)) for lvl, ss in zip(lines.levels, lines.allsegs) for seg in ss if len(seg) > 1]
contours = gpd.GeoDataFrame({"level": [s[0] for s in segs]}, geometry=[s[1] for s in segs], crs="EPSG:27700")
for name, gdf in [("standpipes", standpipes), ("readings", readings), ("limestone_contours", contours)]:
    gdf.to_file(gpkg, layer=name, driver="GPKG")
```

`Output`

```text
=== Step 6: write the standpipes, readings and contours to a GeoPackage ===
a417_groundwater.gpkg | standpipes: 56 Point features in EPSG:27700
a417_groundwater.gpkg | readings: 1764 Point features in EPSG:27700, time 2019-01-31 to 2021-07-23
a417_groundwater.gpkg | limestone_contours: 37 LineString features in EPSG:27700
figures: 01-standpipe-response-zones.png, 02-groundwater-hydrographs.png, 03-depth-to-groundwater-map.png, 04-limestone-groundwater-contours.png, 05-qgis-temporal-frames.png
```

The `readings` layer has 1,764 points, one fewer than the 1,765 readings, because DSRC310’s single dry dip belongs to a pipe with no water level. The `time` field is a real date and time, which is what QGIS needs to animate it.

## Step 7: animate the readings with the QGIS Temporal Controller

`qgis_groundwater.py` builds the QGIS project. Run it with the Python that comes with QGIS, as in Part 2:

```text
"C:\Program Files\QGIS 3.40.12\bin\python-qgis-ltr.bat" qgis_groundwater.py
```

It loads the DTM as a hillshade, the contours with labels, every standpipe as an open circle, and the readings coloured by `change` in five classes, from more than 2 m below the pipe’s median to more than 2 m above. The dry and out-of-step readings are filtered in the layer source, so they never draw. Then it switches on the readings layer’s temporal properties and sets the project’s time range and step:

`qgis_groundwater.py`

```python
readings = QgsVectorLayer(f'{GPKG}|layername=readings|subset="dry" = 0 AND "spike" = 0',
                          "Water level readings", "ogr")
...
temporal = readings.temporalProperties()
temporal.setIsActive(True)
temporal.setMode(Qgis.VectorTemporalMode.FeatureDateTimeInstantFromField)
temporal.setStartField("time")
navigation = project.timeSettings()
navigation.setTemporalRange(QgsDateTimeRange(QDateTime(QDate(2019, 1, 1), QTime(0, 0)),
                                             QDateTime(QDate(2021, 8, 1), QTime(0, 0))))
navigation.setTimeStep(1)
navigation.setTimeStepUnit(QgsUnitTypes.TemporalUnit.TemporalMonths)
navigation.setFramesPerSecond(2)
```

`Output`

```text
QGIS 3.40.12-Bratislava
LIDAR DTM (hillshade): valid=True
Birdlip Limestone groundwater (m OD): valid=True, 37 features
Standpipes: valid=True, 56 features
Water level readings: valid=True, 1733 features
saved output/a417_groundwater.qgz with temporal readings, monthly steps
September 2020: 31 readings in the frame, 14 more than 0.5 m below the pipe's median and 1 more than 0.5 m above; scale 1:19,864; render errors: 0
February 2021: 43 readings in the frame, 0 more than 0.5 m below the pipe's median and 16 more than 0.5 m above; scale 1:19,864; render errors: 0
rendered 05-qgis-temporal-frames.png, 1820 x 1170 px
```

Each reading is an instant in time, so with one-month steps every frame shows the dips made in that month. Open `output/a417_groundwater.qgz` in QGIS, open **View > Panels > Temporal Controller**, choose the animated mode (the play icon) and press play. The groundwater rises and falls across the hillside two frames a second, month by month from January 2019 to July 2021.

To do the same by hand with any layer that has a date field:

1.  Right-click the layer, choose **Properties > Temporal** and tick **Dynamic Temporal Control**.
2.  Set **Configuration** to _Single Field with Date/Time_ and **Field** to `time`. Leave the event duration at 0 so each feature shows only in the step that contains it.
3.  In the Temporal Controller, click **Set to full range** (the refresh icon beside the dates), set **Step** to 1 month and press play.

The script also renders two frames side by side, the image at the top of this page. In September 2020, 14 of the 31 pipes dipped were more than half a metre below their median and only one above it. In February 2021, none of the 43 was below and 16 were above. The `standpipes` layer stays visible in every frame, so you can see which pipes were not dipped that month.

## Frequently asked questions

### Where is groundwater monitoring in an AGS4 file?

In two groups. MONG has one row per installation, with its type and response zone (`MONG_TRZ` to `MONG_BRZ`). MOND has one row per reading, keyed to the installation by `LOCA_ID` and `MONG_ID`, with `MOND_TYPE` saying what was measured. Water level dips are `WDEP` and the depth to the base of the pipe is `DBSE`. Water strikes during drilling are in different groups, WSTG and WSTD.

### How do I tell a dry pipe from a real water level?

Compare the dip with the depth of the pipe. If the “depth to water” is at the base of the pipe, within a few centimetres, the dip meter reached the bottom without finding water. Use the base measured on the same visit (`DBSE`) where there is one, and the installed depth otherwise. Field remarks in `MOND_REM` sometimes say “dry” outright, so read them too.

### Why plot change from the median instead of the water level?

Because the pipes on Crickley Hill span 160 m of elevation, and a 2 m seasonal swing disappears on an axis that wide. Subtracting each pipe’s median puts every pipe on the same zero, so the seasonal pattern, and any pipe that behaves differently, stands out.

### Can I contour groundwater levels from every standpipe together?

Only when the pipes measure the same body of water. Here the pipes in the landslide deposits, the Lias, the Inferior Oolite and the Great Oolite read separate water levels, tens of metres apart in places. Contour one unit at a time, as we did for the Birdlip Limestone, and treat pipes with water only in the sump as an upper limit rather than a level.

### Can I use this with any AGS file?

Yes, if it has MONG and MOND, plus LOCA and GEOL to place the pipes. Check `MOND_TYPE` and `MOND_REM` first, because contractors record water quality depths, dry pipes and missed visits in different ways. Change `DRY_TOL`, `SPIKE` and `SUMP` to suit the site.

## Next steps

-   Part 10 of the series turns to cone penetration tests and how to interpret them from AGS4.
-   [Part 8: laboratory classification](https://www.technicalgis.com/tutorials/ags-laboratory-classification-python/) maps how plastic the clays are that hold up the perched water on the plateau.
-   [Part 5: the ground model](https://www.technicalgis.com/tutorials/geological-ground-model-surfaces-python/) builds the unit surfaces that you could compare with the Birdlip Limestone groundwater contours.
-   Back to [Part 2: mapping the boreholes in QGIS](https://www.technicalgis.com/tutorials/ags4-boreholes-map-qgis/) for more on PyQGIS projects.

## Data and licences

-   **A417 Missing Link ground investigation** (BGS deposited data item 173984; client Highways England, now National Highways; contractor Geotechnical Engineering Ltd). The monitoring groups come from the original AGS4 file deposited with the BGS, and the repaired locations and geology from the BGS AGS export used in Part 1. Contains British Geological Survey materials © UKRI 2026, licensed under the [Open Government Licence v3.0](https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/). Every figure carries the credit.
-   **Environment Agency LIDAR Composite DTM 1 m**, requested at 5 m from the Defra Data Services Platform WCS. © Environment Agency copyright and/or database right, licensed under the Open Government Licence v3.0. It is the hillshade and contours in the maps, which carry the credit. No other basemap is used.
-   Code: [`groundwater_monitoring.py`](https://www.technicalgis.com/code/groundwater-monitoring-ags4-python-qgis/), `qgis_groundwater.py` and `a417_ags.py`, tested with Python 3.12.0, python-ags4 1.2.0, pandas 2.3.3, GeoPandas 1.2.0, rasterio 1.5.2, matplotlib 3.11.2 and QGIS 3.40.12.

## Key terms

- **Standpipe**: A plastic pipe installed in a borehole with a slotted section, the response zone, surrounded by sand or gravel and sealed above and below with bentonite, so the water level in the pipe reflects the groundwater in that zone.
- **Response zone**: The depth range over which a standpipe or piezometer is open to the ground. In AGS4 it is MONG\_TRZ (top) to MONG\_BRZ (base), in metres below ground.
- **Dip**: A manual water level reading taken with a dip meter, a graduated tape that bleeps when its probe touches water. It is recorded as a depth below the top of the pipe or ground level.
- **Hydrograph**: A graph of water level against time for one monitoring point. Plotting change from each pipe's own median lets pipes at very different elevations share one axis.
- **Groundwater divide**: A ridge in the water table. Groundwater flows away from it on both sides, much like a watershed in surface drainage.
- **Temporal Controller**: The QGIS panel that filters time-enabled layers to a moving time window, so you can step through or animate data with a date field.

## Data for this tutorial

-   [BGS AGS borehole data](https://www.technicalgis.com/data-sources/united-kingdom/#src-bgs-ags-borehole-data) · Donated AGS ground investigation data, Open Government Licence

Licences and formats for each source are listed in the [GIS data sources catalogue](https://www.technicalgis.com/data-sources/).

[← Part 8 Laboratory classification data from AGS4: plasticity charts, grading curves and maps in Python](https://www.technicalgis.com/tutorials/ags-laboratory-classification-python/)

---

Source: https://www.technicalgis.com/tutorials/groundwater-monitoring-ags4-python-qgis/
