Constructing and deconstructing geological maps: a QGIS plugin for creating topologically consistent geological cartography
Authors: Penasa Luca , Frigeri Alessandro , Pozzobon Riccardo , Brandt Carlos H. , De Toffoli Barbara , Naß Andrea , Rossi Angelo Pio , Massironi Matteo 
Published: October 2020

Geological maps have been historically a central part of the geological knowledge acquisition process: they are used to summarize all the relevant information of a site of interest and they provide the cornerstone for decision making, scientific discovery and three-dimensional geological modeling.Depending on the scope of the geological survey the cartography can depict different types of content: whether lithostratigrapy, chronostratigrapy, morphology, or other criteria are considered, the building blocks of a geological map is the geological unit, as the base element used to subdivide a region into geologically homogeneous patches of terrain. Digitized maps are normally represented within GIS software as polygonal layers.A common approach for mapping has been to directly draw polygons representing the different units on the map: although this approach appears the simplest one, it poses several issues in terms of topological consistency of resulting maps, especially when it comes to updating existing cartography. Furthermore, from a purely information science standpoint this representation, although useful for visualization, is inherently redundant, defining the same boundary geometry two times for each polygonal couples in contact.Editing polygonal layers is inherently problematic because vertex and edge correspondence between polygons in contact must be enforced by the operator. Although most GIS software implements appropriate tools (for editing and&#160; for topology validation) which can help in achieving error-free polygonal layers, the burden of using them is left to the operator and it is not enforced by the data format itself.A better solution for generating topologically-consistent geological maps consists in tracing the contacts separating the units, and then transforming them into polygonal layers (by using what is often known as a &#8220;polygonize&#8221; operation) for map finalization (see Figure 1).Figure 1: Generation of a consistent polygonal layer by polygonize&#160;operation, this can be performed by any GIS and is suggested as a good practice in geological map generation. A line layer is used for tracing the contacts between the different units and a point layer is also needed to define attributes for the polygons.This approach is also more similar to the geological reasoning that is performed when mapping, especially when remotely&#160;-sensed imagery is used (as in planetary mapping): the operator tries to identify the boundaries between different terrains rather than directly defining the area covered by the units themselves. This strategy hasve the clear benefit of making editing the map easier but, even when employed by the operator, the original layers (contact lines and points) are rarely or never distributed to the public, making it impossible to apply this method when updating already existing maps.In order to solve this problem we implemented a python module and a QGIS plugin called Mappy which is mostly based on already-existent modules as numpy (Oliphant 2006), geopandas (Jordahl et al. 2019), and topojson (Bostock 2017). Mappy implements the backwards transformation of the polygonize operation decomposing a polygonal layer into boundary lines and a point layer that contains the attributes of the original polygonal layer (the forward transform is also implemented).&#160;The input polygonal layer is first transformed into a topology-aware representation via topojson: first the intersection points are detected and then the polygons boundaries are split at those points, creating a list of arcs: each representing an unique portion of a contact line (Figure 2). Topojson representation can also account for rounding errors in the nodes coordinates and makes it possible to also consistently apply line-simplification methods (e.g. to reduce the number of nodes) while maintaining the original topology.Figure 2: The inverse operation of a "polygonize" operation as performed by mappy. a) the input polygonal layers with attributes; b) the topojson representation as list of arcs (each polygon is then just a list of arcs in the right order); c) the arcs are aggregated to create a representation more suitable for geological editing; d) point are positioned in the visual center of each polygon and the attributes are then transferred.Although being topologically sound, the topojson format of a polygonal layer is not the best suited representation for editing geological maps: given each line is split at the intersection points (Figure 2b) a contact might be split in a number of segments (i.e. when a contact separates one unit from several others) making it more difficult to edit the contact of a specific unit. For this reason,&#160;Mappy further processes the lines to aggregate several continuous arcs into a single polylines (Figure 2c).For each polygon an indicator point is then automatically computed to be in its visual center and the original attributes of the polygons are transferred to it. The points are placed by using the &#8220;polylabel&#8221; method provided by shapely module (Gillies and others 2007).The described approach has been then implemented in a standalone module that is also accessible from a QGIS plugin enabling easy transformation of any existing map into a line and points representations and vice-versa, therefore simplifying the process of editing and topology checking of existent geological maps.Acknowledgments: This research was supported by European Union&#8217;s Horizon 2020 under grant agreement No 776276- PLANMAP.References:Bostock, Mike, 2017 TopoJSON. URL: https://github.com/topojson/topojson-specification.Gillies, Sean, and others, 2007 Shapely: Manipulation and Analysis of Geometric Objects. toblerity.org. https://github.com/Toblerity/Shapely.Jordahl, Kelsey, Joris Van Den Bossche, Jacob Wasserman, et al., 2019 Geopandas/Geopandas: V0.4.1. Zenodo. https://zenodo.org/record/2585849, accessed June 29, 2020.Oliphant, Travis, 2006 NumPy: A Guide to NumPy. https://www.numpy.org/.