GerryChain
GerryChain copied to clipboard
Initial EmbeddedGraph implementation.
Because we are often interested in contour-based compactness scores (e.g. Polsby-Popper, Reock, Convex Hull, etc.), this implements the EmbeddedGraph
class where each networkx node stores information about the (multi)polygon to which it's dual. Exterior nodes – those which form the boundary of the jurisdiction – store all the points from their dual polygons, while interior nodes store only the points on their dual polygons' convex hulls. This accomplishes a few things:
- first, we can easily access geometric information about the graph's embedding (or, rather, the embedding of the set of polygons to which the graph is dual) and modify it easily;
- the above enables us to – with some other optimizations/tricks – quickly calculate contour-based compactness scores without storing or otherwise keeping track of extraneous geometric information in other formats (e.g. shapefiles, GeoJSON;
- if we choose not to calculate compactness scores during chain runs, we can store only assignments, then re-project and score after-the-fact.
This is of course a WIP and needs feedback from everyone, but I believe it's a useful tool and can serve us well in future.