Skip to content
GEOSAT
Back to blog
Open GIS
Open GIS2026-09-23GEOSAT6 min read

Editing, validation and topology in QGIS: rules beyond the desktop

Combine forms, geometry checks and database constraints to keep data dependable.

Editorial review: 2026-09-23

QGISPostGISOpen GIS

A form makes data entry easier, but a rule enforced only in the form can be bypassed by another client. Design quality at three levels: storage constraints, geometry validity and domain rules. A valid polygon can overlap another incorrectly while remaining individually valid.

Prepare a small test

In a GeoPackage copy, create test polygons: two neighbors sharing an edge, one containing a small gap and one with a self-intersection. Define the model first: a territorial coverage may prohibit overlaps and gaps, while an influence-area layer may allow them. Do not run bulk repair before deciding what each defect means.

In QGIS configure snapping by layer, units and tolerance. Work at a known scale and enable topological editing where appropriate. Check that moving a shared vertex preserves the intended relationship. An excessive tolerance can move features that should not coincide.

Make rules explicit

Under Layer Properties → Attributes Form, mark required fields and configure code lookups. This QGIS expression checks a nonempty key and a positive declared area; adapt the field names to your synthetic layer:

Code example
"code" IS NOT NULL
AND length(trim("code")) > 0
AND "declared_area" > 0

Test a valid record, an empty code and a zero area. A null area must be rejected by a non-null constraint in addition to the expression. This expression does not establish equality between declared and calculated area or uniqueness of the key.

Move invariants into PostGIS

When multiple clients write to the database, use unique keys, NOT NULL, foreign keys and constraints compatible with the model. An overlap rule spanning rows cannot be solved with a simple per-record CHECK: it needs a transactional strategy and concurrency tests. Form checks remain useful for explaining errors before submission.

Run Check Validity on the copy and review errors by identifier. Fix Geometries can change geometry type or split a feature; preserve the original and result, compare area and part counts, and approve the correction. Avoid declaring a dataset correct merely because every geometry is valid.

Acceptable delivery

Document rules, tolerances and exceptions. Open the table from a second client and attempt an invalid write: essential invariants should still protect the data. Also test editing cancellation and rollback. Identify who reviews conflicts and which report is produced; quality depends on that process as much as the tool.

Define validity, topology and business quality separately

A polygon may be valid as a geometry while overlapping a neighbor it must not overlap. A perfectly snapped line may still point to the wrong asset. Classify checks into three groups before configuring tools:

CheckExampleWhere to enforce or inspect
Geometry validitySelf-intersection or invalid ringGeometry validator; database constraint where appropriate
Cross-feature topologyForbidden overlap, missing connectionRules over the layer or related layers
Business meaningDuplicate asset code, inconsistent statusUnique keys, reference tables and review process

Use a declared tolerance in the units of the working CRS. A screen-pixel snapping tolerance changes its effective ground distance with zoom; a map-unit tolerance has a different operational meaning. Choose deliberately and repeat the same edit at two scales to expose unintended behavior.

A controlled editing rehearsal

Create a disposable GeoPackage with two adjacent squares and a third square separated by a visible gap. Assign codes P-01, P-02 and P-03. The gap is intentional in this exercise. Define which boundary must remain shared and which empty space is legitimate before running automatic tools.

  1. Enable snapping for the target layer and set an appropriate tolerance for the chosen metric CRS.
  2. Move one vertex on the shared edge with topological editing configured. Inspect both polygons; do not infer success from the cursor's snapping indicator.
  3. Undo and repeat without topological editing to make the potential gap or overlap visible.
  4. Run geometry validity checks and the selected topology checks separately. Save error outputs with the source feature identifiers.
  5. Correct one deliberate overlap, rerun checks and confirm that the intentional gap remains unchanged.

The expected result is preservation of the explicitly shared boundary, detection of the planted error and no modification of the intentional gap. This is a proposed exercise; it is not a certification of a cadastral dataset.

Inspect changes before accepting automatic repairs

A “fix geometries” operation can change type, split an object or alter coordinates. Run it into a new layer. Compare feature counts, identifier uniqueness, multipart structure and area using a documented method. Review each changed record if the batch is small; for a larger batch, categorize changes and inspect representative and exceptional cases.

Never repair a legal or engineering boundary merely to satisfy a software check. Return ambiguous cases to the responsible source or reviewer. The role of the tool is to expose a discrepancy; it does not establish which neighboring record is correct.

Prevent invalid values outside the editor

QGIS form constraints improve data entry, but imports and other clients may bypass them. Put shared identifier uniqueness and required relationships in the central write path. Keep visual rules, help text and value labels in the form. In a PostGIS workflow, a database error must reach the analyst clearly rather than appearing as a silent failed save.

For a municipal inventory, test a duplicate code, missing mandatory status, invalid geometry and disallowed state transition independently. Confirm that an error in one feature does not produce an unclear partially accepted batch. Save a copy before bulk updates and use transactions when the provider and workflow support them.

Practical acceptance record

Record the source version, checks executed, tolerance, number of failures by rule, corrections and unresolved cases. “Zero errors” is meaningful only alongside the rules actually executed. Include a known bad feature in the disposable rehearsal to prove the rule detects the intended problem. Then ask a second analyst to repeat the procedure from the saved project.

Technical reference: QGIS editing and snapping.

Sources and documentation

Next step

Continue in the Open GIS collection. For a specific project, use the total-cost calculator and request an assessment.

Related articles