Open wpegden opened 5 years ago
I'd like to add this feature.
One option would be to decompose non-topological polygons into topological data in a way that preserves all of the original spatial information, so you could do a round trip between topological and non-topological formats. This could mean generating a polyline layer for arcs and a table containing a record for each polygon. The attribute table for the arcs layer would be similar to Figure 4.12 on this page: https://saylordotorg.github.io/text_essentials-of-geographic-information-systems/s08-02-vector-data-models.html
If you only wanted connectivity data for running graph algorithms, you wouldn't need the polyline geometry in the arcs layer. A simpler geometrical representation might be useful for visualizing the graph -- for example a layer of straight line segments connecting the centroids of adjacent polygons.
Do you have any preferences concerning the data format?
I'm not sure what is best in general.
For me personally, what I use is a combinatorial embedding of the graph which knows: the areas of each polygon (vertex of the graph) the shared perimeter of each pair of polygons (corresponding to an edge of the graph).
It has to be a combinatorial embeddding, so in particular, the cyclic order of the edges around a vertex should be known somehow.
The file format I currently use is simply a unix-style text file with: header line number of vertices a line for each vertex, which contains a list of neighbors (in clockwise order), the lists of the shared perimeters corresponding to these edges, the area of the vertex, and then extra non-topological data.
I am not sure how general the topology representation is that you have. In my case, polygons are assumed to be pairwise disjoint, so that tangency is only external. There can also be (usually just one) "flipped" polygon, whose interior is unbounded. (For a political districting of a state, this polygon corresponds to the boundary of the state, the "interior" is the outside of the state). These polygons have to be distinguished somehow, because in the combinatorial embedding, the role of clockwise and counterclockwise for their neighbors is flipped.
mapshaper works by building an internal topological representation of the map.
Is it possible (or perhaps: please make it possible!) to export this topological representation in any format?
If someone wants to run graph algorithms on shapefile data, being able to use mapshaper to export the topological representation would be convenient and portable.