QGIS – Supported Topology File Formats

gmlqgistopojsontopology

I would like to know which topology file formats are supported by QGIS.

I am particularly interested in displaying topologies encoded with TopoJSON or GML. But any other portable topology file formats would be useful.

Best Answer

What is topology for you ? (same in your question Python library to create topologies). It seems to me that you mix topology, geometry and file formats

From ArcUser: Understanding Topology

Mathematical topology assumes that geographic features occur on a two-dimensional plane. Through planar enforcement, spatial features can be represented through nodes (0-dimensional cells); edges, sometimes called arcs (one-dimensional cells); or polygons (two-dimensional cells). Because features can exist only on a plane, lines that cross are broken into separate lines that terminate at nodes representing intersections rather than simple vertices.

These are the concepts of the Planar Graph theory (Geospatial Topology, the Basics)

enter image description hereenter image description here

arcs/areas topology and nodes topology, figures from Full planar topology in GRASS (Prima parte) and Full planar topology in GRASS (Seconda parte) (in Italian)

1) According to these principles, a shapefile, or a GeoJSON file, for example, store simple geometries without topology (called "spaghetti" topology): the common arc of two adjacent polygons is coded twice (= 2 closed polygons)

GeoJSON:

"features": [
{ "type": "Feature", "properties": { "id": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 245694.390306939720176, 142516.899188055162085 ], [ 246286.755701988382498, 142258.933612792025087 ], [ 246468.287032729102066, 140778.020125170383835 ], [ 245092.470631325762952, 140510.500269341951935 ], [ 245121.133473021676764, 140988.214297607017215 ], [ 244738.962250409618719, 141523.254009263851913 ], [ 245694.390306939720176, 142516.899188055162085 ] ] ] } },
{ "type": "Feature", "properties": { "id": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 246286.755701988382498, 142258.933612792025087 ], [ 247309.063722475577379, 142707.984799361176556 ], [ 247767.66918961002375, 142526.453468620456988 ], [ 248082.960448264959268, 141523.254009263851913 ], [ 247901.4291175242397, 140806.682966866297647 ], [ 246468.287032729102066, 140778.020125170383835 ], [ 246286.755701988382498, 142258.933612792025087 ] ] ] } } 
]}

2) In contrast, TopoJSON has a true arc-node topology (geometry + topological rules)

The same polygons in the TopoJSON format (Arc-node topology data structures in Python GIS packages)

{'objects': {'name': {u'crs': {u'type': u'name', u'properties': {u'name': u'urn:ogc:def:crs:EPSG::31370'}}, u'type': 'GeometryCollection', 'geometries': [{u'type': u'Polygon', 'properties': {u'id': None}, 'arcs': [[0, 1]]}, {u'type': u'Polygon', 'properties': {u'id': None}, 'arcs': [[2, -1]]}]}}, 'type': 'Topology', 'bbox': [244738.96225040962, 140510.50026934195, 248082.96044826496, 142707.98479936118], 'arcs': [[[4628, 7955], [542, -6738]], [[5170, 1217], [-4113, -1217], [85, 2173], [-1142, 2435], [2856, 4521], [1772, -1174]], [[4628, 7955], [3056, 2044], [1372, -827], [943, -4564], [-543, -3261], [-4286, -130]]], 'transform': {'translate': [244738.96225040962, 140510.50026934195], 'scale': [0.33443326311184524, 0.21977043004492694]}}

Therefore the formats shapefile, GeoJSON and GML have no topology and TopoJSON, yes. All contains geometries.

enter image description here

shapefiles, GeoJSON vs TopoJSON

3) They are other "true" topological data structures in the GIS World (ESRI ArcInfo topology. GRASS vectors topology, PosGIS topology, SpatiaLite topology), look at Are there Desktop GIS alternatives to ArcGIS 10.X for topology and vector conflation?.

enter image description here

ArcInfo Workstation topology,figure from ArcGIS Topology basics

4) But be careful:

  • QGIS (and other Python modules as ogr and Shapely) use the GEOS C++ library (geometries without explicit topology rules, you can use geometric predicates and relationships but polygons = closed rings, for example)
  • and even if the layer is topologically correct in GRASS GIS, ESRI,SpatiaLite, PostGIS or TopoJSON, this would not be the case of the resulting layer in QGIS (Shapefile)

Therefore, you can open world-110m.json (TopoJSON topology) with QGIS but the resulting topology is not preserved if you save it as a shapefile.

You can use the Topology Checker Plugin to control a shapefile, but the resulting layer will remain a shapefile.

Related Question