Alternative object creation using TopoJSON
Today I will present my new approach on data driven topological ‘consistent’ line simplification applied to topologic connected polygonal geometries, proofed and tested on a dataset of administrative units.
You can see in this example, that I had early the idea to implement topologic ‘consistency’ by not removing the connecting (‘anchor-‘) points of the connected polygonal geometries. But this implementation had a big problem:
I was able to only apply topologic consistent simplification to the lines of the dataset, called by the ‘mesh’-function (topojson.v0.js) –> example
- Disadvantage: no access to the corresponding polygon…and therefore…no interactivity like hovering
– or –
apply topologic INconsistent simplification to the polygonal geometries of the dataset, called by the ‘object’-function (topojson.v0.js – this is now ‘feature’ in ~.v1.js) –> example
- Disadvantage: only topological consistent on connecting (‘anchor’-) points but not along the borders
I was NOT able to get topologic consistent polygons!!! Especially, because topojson.v1.js does not offer a possibility to rebuilt the polygonal geometries from the topologic simplified mesh.
So…I had to implement something…
The basic idea consists of the following steps:
- Take arcs of an object (resp. feature) singulary,
- build their geometries (LineString)
- simplify this linear geometry and
- build the polygonal geometries from the simplified arcs
–> this keeps topology of neighbors
Additionally…I know the start- & end-points of each arc…and can define this as ‘anchor point’ (always keep)
–> this keeps topology at least at the connected points
But wait…I spoke about ‘data driven’…where is it?
This is the thing I like on TopoJSON! It is basically a file format to compress the file size…but it can also be used to support keeping topologic consistency! Especially, when you create a TopoJSON-file, you can add different layers to it.
Let’s have a look at an example:
One layer with german states: TopoJSON checks for redundancy within that layer and between the state geometries
–> 1 arc / state border
Two layers with german states and counties: TopoJSON checks for redundancy between the two layers and the inner connectivity of county & state geometries
–> 1 arc / county border & n arcs / state border
Three layers with german states, counties and municipalities: TopoJSON checks for redundancy between the three layers and the inner connectivity of municipality, county & state geometries
–> 1 arc / municipality border & n arcs / county border & m arcs / state border
You can see: The amount of data, within a TopoJSON-file, influences the granularity of the arcs. And that influences also the topologic consistency for the outline simplification. I described, that I set start-&end-points of the arcs as fixed ‘anchor’ points, which will not get removed. When there are more arcs in the file…there will be also more start-&end-points…so there will be more ‘anchor’ points!?!
I made an application to proof this basic idea and visualise the data-driven topologic consistency of line simplification for polygons. The following images show the polygons when all ‘non-anchor’ points are removed from the geometries. I apply Visvalingham-simplification to the borders of german states and set it to the maximum value…so all points are removed instead they are start- or end-points of an arc.
TopoJSON containing 1 layer – only states
–> you see…only start- & end-points and shared borders are kept – slightly topologic consistent but not correct
TopoJSON containing 2 layers – states & counties
TopoJSON containing 3 layers – states, counties & municipalities
–> that looks very good – that is really a simplified version of germany – good inner and outer topologic consistency
So…I hope…I was able to demonstrate my idea.
With this implementation, I am able to apply topologic consistent linear simplification, independent of geometry type. I just simplify the arcs and build the corresponding object from the simplified arc-geometries, afterwards.
I also tried to demonstrate how the layers of a TopoJSON-file influences the application of generalization. I think this is really straight forward…as the data influences it’s own degree of generalization.
Images are too boring and you like it more interactive?!?…play with the application!