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
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.
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)
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.
"Back in the “olden-days” GIS users, particularly ArcInfo users, were well versed in geospatial topology because of the coverage" (Geospatial Topology, the Basics)
But ESRI is not the only solution:
From these beginnings (at the same time as ArcInfo), GRASS GIS is also a full topological GIS with rules that differ from those of ESRI:
The topology in PostGIS is much more recent with other rules
In the GRASS GIS data model are defined various topological elements:
nodes - 0D elements:
for each node is defined which lines/boundaries starts and ends in this node;
lines - 1D elements which cannot form areas:
for each line is defined a start and end node;
boundaries - 1D elements which can form areas:
for each boundary is defined a start and end node, and an area on the left and right
centroid : point located inside area:
for each centroid is defined an area
areas - 2D elements formed by closed set of boundaries and optionally by one centroid located inside the area:
for each area is defined the list of boundaries which forms the area
(outer ring), and the list of isles located inside the area
isle - 2D elements formed by areas:
for each isle is defined the list of boundaries which forms the isle (it's outer ring),
and optionally by the area where the isle is located.
The PostGIS Topology Model:
The model defines only topological elements
nodes - 0D elements
Is defined by geometry (point) and by the face where the node is located (can be NULL)
edges - 1D elements
Is defined by geometry (linestring), start and end node, next left and right edge
(ie. connectivity) and by the face on the left and right.
faces - 2D elements
Is defined by bounding box.
So:
when you import a shapefile or a QGIS layer in GRASS GIS, they are modified to comply with the topological rules (GRASS layers, see Vector data processing in GRASS GIS, v.clean,v.build)
The same is true when digitizing new vector maps
You can use GRASS GIS only or GRASS GIS from QGIS with the grass plugin or the Sextante plugin, but be careful, even if the layer is topologically correct in GRASS GIS, this would not be the case of the resulting layer in QGIS (no topology) !
from itertools import chain
def rel2abs(arc, scale=None, translate=None):
"""Yields absolute coordinate tuples from a delta-encoded arc.
If either the scale or translate parameter evaluate to False, yield the
arc coordinates with no transformation."""
if scale and translate:
a, b = 0, 0
for ax, bx in arc:
a += ax
b += bx
yield scale[0]*a + translate[0], scale[1]*b + translate[1]
else:
for x, y in arc:
yield x, y
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
These are the concepts of the Planar Graph theory (Geospatial Topology, the Basics)
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:
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)
Therefore the formats shapefile, GeoJSON and GML have no topology and TopoJSON, yes. All contains geometries.
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?.
ArcInfo Workstation topology,figure from ArcGIS Topology basics
4) But be careful:
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.