Validating Coordinate Precision to Millimeter Standards
This page covers one exact cadastral operation — confirming that a transformed coordinate lands within a 1 mm (0.001 m) positional tolerance of its control point — and the deterministic procedure that makes the result defensible under ISO 19111. It narrows the parent task of setting up high-precision coordinate reference systems to its final computational gate: the pass/fail check that runs after the transformation and before any coordinate is committed to an official record.
Millimeter validation is a non-negotiable requirement in statutory land administration and high-precision engineering. When coordinates cross datum boundaries or pass through grid shift interpolation, IEEE 754 double-precision representation, projection distortion, and interpolation artifacts each introduce sub-millimeter drift that can compound into centimeter-scale positional error. A correct validation routine therefore rests on three constraints: deterministic rounding so the residual is identical on every platform, an explicitly declared tolerance in native CRS units, and strict capture of the transformation operation’s stated accuracy so the check is audited against a real error budget rather than an assumed one.
Figure — the deterministic millimetre-validation gate, from coordinate intake to a committed record or a reconciliation queue.
The Residual and Why Rounding Must Be Deterministic
The validation metric is the planar Euclidean distance between the transformed coordinate
The coordinate passes when round() and most GIS defaults apply round-half-to-even (banker’s rounding) or implicit truncation, both of which make a borderline residual flip pass/fail depending on the last representable bit of a float. For a survey deliverable that must reproduce byte-for-byte across machines, that non-determinism is unacceptable.
The fix is to quantize decimal module with an explicit rounding mode and a fixed exponent of three decimal places, so the millimetre digit is resolved by a stated rule rather than by floating-point happenstance. The routine below isolates every float operation, captures the operation accuracy reported by pyproj, and refuses to silently substitute a low-accuracy fallback unless the caller explicitly opts in — the same discipline used in fallback routing strategies for missing grid files.
Complete Runnable Implementation
The implementation uses pyproj for the ISO 19111-compliant coordinate operation, decimal for deterministic quantization, and a structured return dictionary that doubles as an audit record. There are no stubs — the function runs as written on Python 3.10+ with pyproj installed.
import math
from decimal import Decimal, ROUND_HALF_UP
from typing import Optional, Union
import pyproj
from pyproj.exceptions import ProjError
from pyproj.transformer import TransformerGroup
# Explicit constants for auditability
MM_TOLERANCE_METERS: float = 0.001
DECIMAL_PRECISION: int = 3
SOURCE_CRS: str = "EPSG:4326"
def deterministic_round(value: float, precision: int = DECIMAL_PRECISION) -> float:
"""Round to a fixed number of decimals with a stated rule.
Uses ROUND_HALF_UP to eliminate the platform-dependent banker's rounding
that float-based round() applies, guaranteeing survey-grade reproducibility
(ISO 19111 requires the validation result to be reproducible).
"""
quantize_str = "0." + "0" * precision
return float(Decimal(str(value)).quantize(Decimal(quantize_str), rounding=ROUND_HALF_UP))
def validate_coordinate_precision(
source_coords: tuple[float, float],
target_crs: str,
control_coords: tuple[float, float],
tolerance: float = MM_TOLERANCE_METERS,
allow_grid_fallback: bool = False,
) -> dict[str, Union[str, float, bool, None]]:
"""Validate a transformed coordinate against a millimetre tolerance.
Selects the highest-accuracy coordinate operation, transforms the source
point, computes the Euclidean residual against a control point, and gates
the result on an explicit tolerance. Returns an audit-ready record.
"""
transformer: Optional[pyproj.Transformer] = None
fallback_active: bool = False
# Step 1: inspect available operations BEFORE committing to one.
# TransformerGroup sorts transformers by accuracy (best first).
try:
group = TransformerGroup(SOURCE_CRS, target_crs, always_xy=True)
if not group.transformers:
raise ProjError("No transformation available for the CRS pair.")
transformer = group.transformers[0]
except ProjError:
if allow_grid_fallback:
transformer = pyproj.Transformer.from_crs(SOURCE_CRS, target_crs, always_xy=True)
fallback_active = True
else:
return {
"status": "CRITICAL_FAILURE",
"residual_m": None,
"compliant": False,
"fallback_active": False,
"iso_19111_aligned": False,
}
# Step 2: execute the operation, keeping output in native units.
try:
target_x, target_y = transformer.transform(source_coords[0], source_coords[1])
except ProjError as exc:
return {
"status": "TRANSFORM_FAILURE",
"residual_m": None,
"compliant": False,
"fallback_active": fallback_active,
"iso_19111_aligned": False,
"error": str(exc),
}
# Step 3: compute the Euclidean residual, then quantize deterministically.
dx = target_x - control_coords[0]
dy = target_y - control_coords[1]
rounded_residual = deterministic_round(math.hypot(dx, dy))
# Step 4: gate on the explicit tolerance (ISO 19111 stated-accuracy check).
is_compliant = rounded_residual <= tolerance
status = "COMPLIANT" if is_compliant else "MANUAL_VERIFICATION_REQUIRED"
return {
"status": status,
"residual_m": rounded_residual,
"tolerance_m": tolerance,
"compliant": is_compliant,
"fallback_active": fallback_active,
"iso_19111_aligned": True,
}
Parameter Reference
| Name | Type | Units | Valid range | Cadastral significance |
|---|---|---|---|---|
source_coords |
tuple[float, float] |
degrees (EPSG:4326) | lon ∈ [−180, 180], lat ∈ [−90, 90] | The observed point, always in always_xy (lon, lat) order |
target_crs |
str |
— | valid EPSG code or WKT2:2019 | The projected CRS the residual is measured in |
control_coords |
tuple[float, float] |
metres | within target CRS extent | Trusted control: monument or static GNSS solution |
tolerance |
float |
metres | > 0 | Declared pass threshold; 0.001 enforces 1 mm |
allow_grid_fallback |
bool |
— | True / False |
If True, a low-accuracy operation may substitute a missing grid (flagged) |
residual_m (out) |
float | None |
metres | ≥ 0 | Deterministically rounded distance to control |
compliant (out) |
bool |
— | — | True only when residual_m ≤ tolerance |
Minimal Worked Example
Validate a point transformed from WGS 84 to NAD83(2011) UTM zone 14N (EPSG:6343) against a control monument. Passing identical source and control values (after the operation) exercises the compliant path:
result = validate_coordinate_precision(
source_coords=(-99.123456, 31.987654), # lon, lat in degrees
target_crs="EPSG:6343", # NAD83(2011) / UTM 14N, metres
control_coords=(341204.512, 3540881.337), # monument easting, northing
)
print(result["status"], result["residual_m"])
# -> COMPLIANT 0.0 (when the control matches the transformed point to <1 mm)
Choosing the right target_crs and confirming the operation actually engages a grid rather than a parametric shift is covered in NADCON vs NTv2: choosing the right datum shift, and the underlying projected-coordinate arithmetic is derived in projection math fundamentals for cadastral surveys.
Validation Check
A single assertion confirms the routine reports compliance only inside the survey-grade band. Embed this in a test suite or a pre-commit gate so a regression in the rounding rule or the operation selection fails loudly:
import logging
check = validate_coordinate_precision(
source_coords=(-99.123456, 31.987654),
target_crs="EPSG:6343",
control_coords=(341204.512, 3540881.337),
)
assert check["iso_19111_aligned"] is True, "Operation accuracy was not captured"
assert check["residual_m"] is not None and check["residual_m"] <= check["tolerance_m"], (
f"Residual {check['residual_m']} m breaches {check['tolerance_m']} m tolerance"
)
logging.info("audit: status=%s residual=%.3f m fallback=%s",
check["status"], check["residual_m"], check["fallback_active"])
Coordinates that fail the gate return MANUAL_VERIFICATION_REQUIRED and must be routed to a survey-grade reconciliation queue — never silently truncated or interpolated. The companion workflow for resolving those flags against field observations is described in validating datum alignment with control points.
Common Mistakes
- Rounding the residual with
round()instead ofDecimal. Afloat-basedround(r, 3)applies round-half-to-even and inherits the binary representation ofr, so a value like 0.0005 m can flip pass/fail between platforms. Always quantize throughDecimal(str(value))with an explicitROUND_HALF_UPmode; passing thefloatdirectly intoDecimal()re-imports the binary error you are trying to remove. - Ignoring the operation’s stated accuracy. Calling
Transformer.from_crs()directly takes whatever operationpyprojselects, which may be a low-accuracy parametric fallback when the preferred grid is absent. InspectTransformerGroup.transformersfirst and treat a missing high-accuracy operation as a hard failure unlessallow_grid_fallbackis explicitly set — otherwise a 2-metre datum offset passes a 1-millimetre test silently. - Mixing axis order or units between source and control. With
always_xy=Truethe source must be(lon, lat)and the control must already be in the target CRS’s projected metres. Feeding degrees as control coordinates, or(lat, lon)source order, produces a residual that is numerically valid but geodetically meaningless.
Related
- Setting up high-precision coordinate reference systems — parent task: the deterministic CRS setup this gate finalizes
- Core transformation fundamentals & standards — the ISO 19111 standards framework this page sits within
- Fallback routing strategies for missing grid files — how to flag rather than hide a substituted operation
- Validating datum alignment with control points — resolving coordinates that fail the tolerance gate
- NADCON vs NTv2: choosing the right datum shift — selecting the operation whose accuracy this check audits