Utility mapping data is only useful if a designer can trust it years after the survey crew has left. A line on a drawing that says "water main" is not enough. The record needs to say how deep the pipe is, how it was found, when, and how confident the surveyor was. In this tutorial we will build that kind of utility mapping layer in Python with GeoPandas, compare it against an asset owner's old record drawing, and export a reconciliation schedule plus GIS files that a CAD or GIS team can open straight away.
The example data is small and made up, but the structure follows how buried services are recorded on real underground utility surveys in India.
Why accurate utility maps are important
Construction projects in Indian cities rarely start on empty ground. Roads, campuses and industrial areas already hold power cables, OFC ducts, water mains, sewers and gas lines, often laid by different agencies over decades. Accurate maps help planning teams route new work around these assets, place trial pits where they matter and reduce the risk of a utility strike. The location information collected in the field is the important part; the software only provides a way to store it, check it and share it. That is why the data model matters as much as the survey itself.
What a good utility map record holds
Field detection with ground penetrating radar (GPR) and electromagnetic (EM) locators tells you where a cable or pipe is. Mapping turns that evidence into a maintainable record of buried assets. Each feature in the layer should include its own attributes:
- util_id – a unique reference used on drawings and in the report
- service – power, telecom, water, sewer, gas or unknown
-
method – how it was detected, for example
GPR,GPR+EMorrecords - depth_m – detected depth in metres
- q_level – the quality level, D to A, based on the PAS 128 convention (D = desktop records only, A = physically exposed and verified)
- surv_date – when the line was surveyed
Keep field names at 10 characters or fewer. Shapefiles still truncate longer names, and many clients still ask for SHP.
Setup
pip install geopandas pyogrio
We work in a projected CRS so that distances come out in metres. For sites around Delhi NCR, WGS 84 / UTM zone 43N (EPSG:32643) is a good choice.
Step 1: Build the detected utilities layer
import geopandas as gpd
import pandas as pd
from shapely.geometry import LineString
CRS = "EPSG:32643" # WGS 84 / UTM zone 43N, metres (covers Delhi NCR)
# Field detections from the GPR + EM survey
detected = gpd.GeoDataFrame(
{
"util_id": ["P-01", "T-01", "W-01", "U-01"],
"service": ["power", "telecom", "water", "unknown"],
"method": ["GPR+EM", "GPR", "GPR+EM", "GPR"],
"depth_m": [1.10, 0.75, 1.60, 2.05],
"q_level": ["B", "B", "A", "B"],
"surv_date": ["2026-11-10"] * 4,
},
geometry=[
LineString([(718000, 3141000), (718120, 3141002.5)]),
LineString([(718000, 3141010), (718120, 3141011)]),
LineString([(718000, 3141020), (718120, 3141020)]),
LineString([(718060, 3140990), (718062, 3141030)]),
],
crs=CRS,
)
Note the unknown service U-01. A congested street with no unknown lines on the drawing is usually a sign that something was left out, not that nothing was there.
Step 2: Load the owner's record drawing
Old drawings from the asset owner are a starting hypothesis, not a record. Digitise them into a second layer:
records = gpd.GeoDataFrame(
{
"rec_id": ["R-PWR-7", "R-TEL-2", "R-WTR-1", "R-GAS-4"],
"service": ["power", "telecom", "water", "gas"],
},
geometry=[
LineString([(718000, 3141000), (718120, 3141000)]),
LineString([(718000, 3141013), (718120, 3141013)]),
LineString([(718000, 3141020), (718120, 3141020)]),
LineString([(718000, 3141040), (718120, 3141040)]),
],
crs=CRS,
)
Step 3: Compare records with the ground
For each record line, we look for the closest detected line of the same service. A plain distance() only gives the nearest point, which hides a pipe that drifts away from the drawing along its length. The Hausdorff distance gives the worst offset anywhere along the line, which is what a drilling crew cares about.
def compare(rec, found, ok_m=0.5, max_m=3.0):
"""Match one record line to the closest detected line of the same service."""
same = found[found["service"] == rec["service"]]
if same.empty:
return None, None, "not found in field"
# Hausdorff distance = the worst offset anywhere along the line
offsets = same.geometry.apply(rec.geometry.hausdorff_distance)
best = offsets.idxmin()
off = round(float(offsets[best]), 2)
if off <= ok_m:
status = "confirmed"
elif off <= max_m:
status = "position differs"
else:
status = "not found in field"
return same.loc[best, "util_id"], off, status
The tolerances are project choices. Agree them with the client before the survey starts, along with the coordinate system and layer names. Tighter values suit dense urban areas and HDD crossings; looser ones may be fine for early planning on open ground.
Step 4: Build the reconciliation schedule
The reconciliation schedule lists every difference between the records and the ground. On most networks it is the single most valuable output of a mapping survey, because it tells engineers which drawings to stop trusting.
rows = []
for _, rec in records.iterrows():
util_id, off, status = compare(rec, detected)
rows.append({"rec_id": rec["rec_id"], "service": rec["service"],
"util_id": util_id, "offset_m": off, "status": status})
# Lines found in the ground that no record mentions
matched = {r["util_id"] for r in rows if r["status"] != "not found in field"}
for _, det in detected[~detected["util_id"].isin(matched)].iterrows():
rows.append({"rec_id": None, "service": det["service"],
"util_id": det["util_id"], "offset_m": None,
"status": "not on records"})
schedule = pd.DataFrame(rows)
print(schedule.to_string(index=False))
Output:
rec_id service util_id offset_m status
R-PWR-7 power P-01 2.5 position differs
R-TEL-2 telecom T-01 3.0 position differs
R-WTR-1 water W-01 0.0 confirmed
R-GAS-4 gas NaN NaN not found in field
NaN unknown U-01 NaN not on records
Read it like an engineer would. The water main matches. The power cable and telecom duct exist but are drawn in the wrong place, by up to 2.5 m and 3 m. The gas line on the drawing was not detected, so it may be abandoned, deeper than radar reach or simply wrong on paper. U-01 is in the ground but on no drawing at all. Both of the last two cases are candidates for a trial pit before excavation.
Step 5: Export the layers
detected.to_file("utility_map.gpkg", layer="detected_utilities", driver="GPKG")
detected.to_file("detected_utilities.shp")
detected.to_crs("EPSG:4326").to_file("detected_utilities.geojson", driver="GeoJSON")
schedule.to_csv("reconciliation_schedule.csv", index=False)
GeoPackage is the cleanest format for a GIS team. The shapefile keeps older systems happy, and GeoJSON in WGS 84 is easy to drop onto a web map. If the client wants KML for Google Earth, convert the GeoJSON with ogr2ogr -f KML detected_utilities.kml detected_utilities.geojson.
Step 6: Checks before you issue the data
A few lines of code catch most problems before a drawing goes out:
low = detected[detected["q_level"].isin(["C", "D"])]
print("Lines below quality level B:", len(low))
print("Unknown services to trial-pit:",
list(detected.loc[detected["service"] == "unknown", "util_id"]))
Other useful checks:
- every feature has a depth, method, quality level and survey date
- no two lines of different services sit on top of each other
- the same depth value is not repeated along a whole route (a sign of copied data)
- coverage gaps, such as wet clay, saline ground or reinforced concrete, are recorded in the report
Where this fits in a real project
The code above handles the data side. The hard part is the field evidence that goes into it: GPR traverses on a grid, EM tracing, surveyed chambers and valves, and a DGPS or total-station tie-in so every line sits on the project grid. Without that, any GIS layer is just a neat picture of guesses.
Mezux Touch, an underground survey company in Faridabad working since 2003, runs this kind of work as utility mapping with confidence stated per feature and a reconciliation schedule against the owner's records. Its CAD and GIS utility mapping deliverables cover DWG, SHP, KML and PDF, built on field data from its own GPR survey crews.
If you write tools for infrastructure teams, keep the attributes with the geometry. A line that knows how it was found is worth far more than a line that only looks right.
Top comments (0)