1 of 30

Postgis topology workshop session

Setting up a boundaries database with PostGIS topology

Benjamin Deswysen

2 of 30

Benjamin Deswysen

→ Geomatician @GeoPostcodes

Polleur (Liège, Belgium)

ULiege, UNamur

Geo data science & engineering

OSM occasional contributor

2

© Taïs Grippa - 2023

3 of 30

4 of 30

4

5 of 30

5

6 of 30

6

“A collection of vector polygons representing either postal code or administrative division shapes.”

Boundaries database

7 of 30

GeoPostcodes products

“A truly global data set containing all administrative divisions, cities and postal codes for 247 countries.”

Worldwide postal database

8 of 30

GeoPostcodes products

“A collection of vector polygons representing either postal code or administrative division shapes.”

Boundaries database

9 of 30

GeoPostcodes products

“Complete your geo data with street-level information for address validation, autocomplete, and last-mile delivery.”

Streets database

10 of 30

01

Topology in GIS

11 of 30

Topology

Geography <=> Territory delimitations and “ownership”

12 of 30

Topology

Geography <=> Territory delimitations and “ownership”

    • Political boundaries
    • Administrative divisions
    • Economic zones
    • Urban areas
    • Cultural regions

13 of 30

Topology definition

Topology expresses the spatial relationships between connecting or adjacent vector features (points, polylines and polygons) in a GIS.

Topological or topology-based data are useful for detecting and correcting digitising errors (e.g. two lines in a roads vector layer that do not meet perfectly at an intersection). Topology is necessary for carrying out some types of spatial analysis, such as network analysis.

14 of 30

Topology errors

  1. Undershoot: vector lines that should connect to each other don’t quite touch
  2. Overshoot: line ends beyond the line it should connect to
  3. Slivers: vertices of two polygons do not match up on their borders.

15 of 30

Topology rules examples

  • Area edges of a municipality map must not overlap.�
  • Area edges of a municipality map must not have gaps (slivers).�
  • Polygons showing property boundaries must be closed. �Undershoots or overshoots of the border lines are not allowed.�
  • Contour lines in a vector line layer must not intersect (cross each other).

16 of 30

02

Postgis topology

= postgresql extension

17 of 30

- 4 Edges

- 4 Nodes

17

Example of polygon boundaries

1 Polygon

18 of 30

18

GIS topology = outgrowth of graph theory

It’s a �graph!

19 of 30

Postgis topology datamodel

=> Topological primitives

“lines”

“polygons”

“points”

20 of 30

Postgis topology datamodel

Face

Edge

Node

21 of 30

Topogeometry type

Topogeometry = postgis topology column type

= layers (groups) of primitives

= composed object � (topology_id, layer_id, topogeo id, type)�

  • Doesn’t contain any geometry directly, only references
  • A table in topology needs a topogeometry column
  • Documented in topology.layer and topology.topology metadata tables

Topology ≠ Geometry

22 of 30

Advantages of postgis topology

  • Storage: store only once the shared edges�
  • Edition: edit shared edges, not polygons�
  • Detect topologic errors: gaps/overlaps�
  • Simplification: simplify edges, not polygons�
  • Implement nested boundaries: aggregate features based on an admin hierarchy

23 of 30

Advantages of postgis topology

  • Nested boundaries: aggregate features based on hierarchy

24 of 30

Advantages of postgis topology

  • Simplification: simplify edges, not polygons

25 of 30

VIZ / HPR boundaries databases

Simplification

Real polygon

26 of 30

Simplification: careful with tolerance value

1 Polygon� - 2 Edges� - 2 Nodes

Simplification

→ Oversimplification = Empty geometry!

27 of 30

Simplification: careful with tolerance value (2)

1 Polygon� - 2 Edges� - 2 Nodes

Densify topology� - 5 Edges� - 5 Nodes

Simplification

28 of 30

03

Q&A

Any questions?

29 of 30

04

Workshop

Get your hands dirty!

30 of 30

https://bdeswysen.gitlab.io/postgis_topology_workshop