This demonstration was created in preparation for the EDC-Entwicklerforum at the Dresden University of Technologies in 2013.
It should basically demonstrate:
- the 'beauty' of managing and sharing Code via GitHub-Gist & bl.ocks.org
- in how far 'TopoJSON' is applicable and benificial for simplification of polygons
Especially bl.ocks.org enables the parallel view of...
- JavaScript-, CSS- and HTML-Documents
- descriptions on the code (or project) in a readme.md file
- the resulting visualisation That is really benifitial for understanding foreign code!!!
Basically, you see a background map, made with Lealfet, and surely you have already recognized the 'animation selection menu'!
You've got 3 options:
- 'Start the complete animation'
- start each part animation ('...without topology', '...regarding topology', 'data-driven...', 'Result')
- test the simplification of arcs manually ('Simplify manually')
'...without topology'
You can see the status-qou! Say we've got a GeoJSON-file containing the boundaries of the german states. The effect of applying a simple point reduction (simplification) on these polygons is obvious ... it destroys the topology of our data. Whereby we see a lot of 'holes'/'leaks' along the boundaries!
'...regarding topology'
TopoJSON helps us to avoid the destruction of topology, because each redundant line segment it stored only once ... called 'Arc'! You can see the effect in the animation of the TopoJSON-file with the same content... we just reduce the number of points (simplify) of each line segment ('Arc') and preserve the Start- & End-Point of each one! In result, we can - at least - keep the topology at these points and along the boundaries...but the form of the german states is still heavily distorted when we apply a very high 'tolerance' to the simplification algorithm.
'data-driven...'
We are able to avoid this, by adding more data to the TopoJSON-file. I added another TopoJSON-file to the demo, which contains the boundaries of german counties, additionally. As the counties share boundaries also with the states, do these consist now of way more line segements ('Arcs')!!! You can see that when the 'ids' are displayed! And this helps already...we just do the same as before, just simplify the 'Arcs' and preserve Start-& End-Points. The effect is great! The topology is basically preserved much better than before, even for the maximum tolerance, and also the form of the german states enables you to deduce the original form!
You see the TopoJSON-file, respectively the data within, defines how much you can simplfiy (& distort) the polygonal geometries. Following the typonomy of D3 ... I understand this as 'data-driven degree of simplification'!
'Result'
Finally, you can see the resulting Polygons, built from the simplified 'Arcs'!
- No 'holes' or 'leaks' ... thanks to the uniqueness of 'Arcs'!
- The form looks pretty similar to the original form ... thanks to the detailedness of the TopoJSON-file