Topology, did you say topology?

This article explores the fundamental concept of topology in GIS (Geographic Information Systems) and its application in the modeling and analysis of geospatial data. It examines in detail the different aspects of topology, such as spatial relationships, topological constraints and topological operations.

It explains how topology can be used to represent and manage spatial connections between geographic entities, ensuring data consistency and integrity. It highlights the benefits of using topology, such as detecting geometry errors, managing overlays and performing advanced spatial analyses.

The article also discusses the tools and functionalities available in GIS software, such as QGIS and PostGIS, for implementing and exploiting topology. It offers concrete examples and practical advice for working with topology in a GIS context, giving readers a thorough understanding of its importance and applications.

Topology is a branch of mathematics and geometry that studies the spatial properties of objects and their relationships. In geography and GIS (Geographic Information Systems), topology is used to describe and analyze the spatial relationships between geographic entities, such as points, lines and polygons.

Topology is used to define rules and constraints on how geographic entities are connected, share boundaries or overlap. It provides a network structure for representing and understanding spatial relationships more precisely.

The key concepts of topology include nodes (junction points), edges (lines connecting nodes) and faces (regions bounded by edges). These elements are used to describe topological relationships such as connectivity, contiguity, adjacency and superposition between geographical entities.

The use of topology in GIS offers numerous advantages, such as managing geometric errors, guaranteeing the integrity of spatial data, facilitating advanced spatial operations (such as intersections and buffers) and creating transportation or hydrographic networks.

In short, topology is a discipline that studies the spatial relationships between geographic objects, enabling better understanding and accurate analysis of spatial data.

Topological representation is based on the premise that, in reality, geometric features are rarely independent of one another. For example, when we look at a city from space, we see a complex network of streets delimiting interlocking city blocks.

With a classical geometric model, we would use lines to represent the streets and polygons to represent the blocks. However, once the streets have been drawn, we already know exactly where the blocks are located. The need to create polygons for them then becomes superfluous. This is where topology comes in.

By using topology, we can avoid this redundancy by linking shared boundaries and areas only once in the database. In this way, geometries that share these boundaries are linked together. This saves time and storage space, while providing a better representation of actual spatial relationships.

By adopting topology, you take an important step towards understanding geometric modeling and its practical applications.

In our last two articles (Eliminate overlaps and gaps between polygons in a layer (with QGis and Postgis)), and Eliminate overlaps and gaps between polygons in a layer (with QGis and Geopackage)) we mentioned the “topological consistency” of a layer.

This layer represented localities, but with empty spaces between the polygons.

We saw two procedures for eliminating these empty areas and obtaining a more aesthetic representation for display and printing, by having a single boundary between the polygons. We’ve misused the term “topological consistency” instead of “geometric consistency”. Let’s take a closer look.

Topology in PostGIS

In PostGIS, there are three types of representation for vector data.

  • The standard geometric model: Each geometry is a separate unit, and shared elements, such as surface boundaries (polygons), are duplicated in each geometry.
  • The geographic model: treats each piece of space as a separate unit, while duplicating boundaries, but considers these units in spheroidal rather than planar space.
  • The topological model: This offers a 2D view of the world similar to the geometric model, but with one essential difference. In the topological model, boundaries and shared zones are stored once in the database and linked to the geometries that share these boundaries. These geometries, whose edges are linked, are called “topogeoms”.

These different representations make it possible to choose the best approach according to the specific needs of spatial analysis.

In the two articles mentioned, what we have obtained are polygons with boundaries that merge perfectly. It’s impossible to distinguish these polygons from those resulting from a topology. And for our intended use (display or printing), the fact that these polygons are geometrically coherent is the same as if they were topologically coherent.

On the other hand, if we had planned to edit the geometries, by modifying the boundaries, there would be a big difference, because in one case we’d have two superimposed lines as boundaries and in the case of a true topology we’d have just one line.

Topological editing in QGis

To make things easier to understand, but also to make things easier to work with, QGis offers a “topological editing” tool:

topologicalEditing

Topological editing : This button helps you edit and maintain shared boundaries between entities. When enabled, QGIS “detects” shared boundaries. When you move shared vertices/segments, QGIS also moves them into the geometries of neighboring entities.

To understand this tool, it simulates a topological construction. When two boundaries are superimposed, it associates them and any modifications are made twice, once on each boundary.

For manual updating of polygons, this tool is very useful. But the usefulness of a true topology goes far beyond this type of operation.

A topology is a concept where objects are defined by their relationships rather than their geometries. Instead of lines, we manipulate edges, nodes and faces.

A topological network is assumed to have its lines (edges) connected to single points (nodes).

Creating topologies in Postgis

The principle is simple: starting from a layer containing geometries, we create and feed three main tables:

  1. a table of lines (edges) with the lines if it’s a Polyline layer, or with the lines that outline surfaces if it’s a Polygon layer.
  2. a table of points (nodes) with the intersections of the lines in the previous table
  3. a table of the rectangular footprints (faces) of the lines or polygons of the other two tables.

To fully understand the difference between a layer’s geometries and its topology, it’s best to look at the attribute tables for each element.

The original layer with geometries

If we take the lieux-dits layer and look at its attribute table:

Attributes are linked to layer identifiers. Each locality is located in a commune, has a name and a creation and update date.

Postgis topology tables

The following SQL script is used:

SELECT topology.CreateTopology('LD_topo', 2154); 
SELECT topology.AddTopoGeometryColumn('LD_topo', 'public', 'LD', 'topo_geom', 'polygon')
UPDATE public."LD" SET topo_geom = topology.toTopoGeom(geom, 'LD_topo', 1, 20.0);

The first line creates a schema to host the layer topology (LD_topo)

The second adds a new column to the original layer to accommodate the topological geometry (topo_geom)

The third fills this new column with the topological version of the geometry, with a tolerance of 20 meters, i.e. all nodes within 20 meters will be considered common. The resulting LD.topo_geom table will have a geometry column (geom) with the original geometry, and a geometry column (topo_geom) with the corrected, topologically correct geometry.

When we open the attribute table, we see a geom column, which is the original geometry. In the background, you’ll notice that the spaces between the localities have been corrected in the new topology.

What do we find in the three topology tables?

The nodes and faces table simply contains an identifier. It’s the edges table that contains the real information:

For each polyline constituting the polygon boundaries, the table indicates:

  • start node
  • end node
  • the line (edge) before the start point
  • the line (edge) after the end point
  • the polygon (face) to the left of the line
  • the polygon (face) to the right of the line

Conclusion: when and why use topology in Postgis?

Using topology in PostGIS offers a number of interesting advantages and functionalities:

  1. Spatial integrity: Topology helps maintain the spatial integrity of geospatial data by ensuring that geometries respect topological rules. This prevents geometric errors such as overlaps, gaps or unauthorized intersections between entities.
  2. Advanced topological operations : Topology enables advanced operations to be performed based on the spatial relationships between entities, such as intersections, unions, differences, cuts, etc. These operations take into account the topological structure of the data, delivering accurate and consistent results.
  3. Digitization error management: Topology enables the detection and resolution of digitization errors, such as geometry or topological errors, by providing tools to simplify, clean and correct data.
  4. Traceability of modifications : Topology records changes made to geospatial data, making it easy to track modifications and manage data versions.
  5. Optimized spatial queries: Using topology, spatial queries can be optimized by exploiting the topological structure of the data. This improves the performance of spatial queries, particularly for complex or voluminous data.
  6. Integration with other GIS tools : PostGIS topology is compatible with other GIS tools, such as QGIS, enabling seamless integration and interoperability between different platforms.

In short, the use of topology in PostGIS makes it possible to improve the quality of geospatial data, perform advanced operations based on spatial relationships and optimize spatial queries, offering better management and analysis of geographic data.

Si cet article vous a intéressé et que vous pensez qu'il pourrait bénéficier à d'autres personnes, n'hésitez pas à le partager sur vos réseaux sociaux en utilisant les boutons ci-dessous. Votre partage est apprécié !

Leave a Reply

Your email address will not be published. Required fields are marked *