The next operation delivered in the build-out of Simple Polygonal Coverages in the JTS Topology Suite is Coverage Union. This is simply the topological union of a set of polygons in a polygonal coverage, producing one or more polygons as the result. (This is sometimes called "dissolve" in the context of polygonal coverages.)
Union of polygons has long been available in JTS, most recently (and robustly) as the UnaryUnion capability of OverlayNG. This makes use of the Cascaded Union technique to provide good performance for large sets of polygons. But the constrained structure of polygonal coverages means unions can be computed much faster than even Cascaded Union. Essentially, the duplicated inner edges of adjacent polygons are identified and discarded, leaving only the outer boundary of the unioned area. Because a valid polygonal coverage has edges which match exactly, identifying duplicate segments can be done with a fast equality test. Also, there is no need for computationally-expensive techniques to ensure geometric robustness.
This is now available in JTS as the CoverageUnion class.
To test the performance of Coverage Union we need some large clean polygonal coverages. These are nicely provided by the GADM repository of worldwide administrative areas.
Here is some metrics comparing the performance of Coverage Union against OverlayNG Unary Union (which uses the Cascaded Union technique). Coverage Union is much faster for all sizes of dataset.
|Dataset||Polygons||Vertices||Coverage Union||OverlayNG Union||Times Faster|
|France level 4||3,728||407,102||0.3 s||8.5 s||28 x|
|France level 5||36,612||729,573||1.07 s||13.9 s||13 x|
|Germany level 4||11,302||2,162,184||0.68 s||27.3 s||40 x|
Union by Attribute
It's worth noting that unioning a set of polygons in a coverage leaves the boundary of the unioned area perfectly unchanged. So subsets of a coverage can be unioned, and the result still forms a valid polygonal coverage. This provides a fast Union by Attribute capability, which is a common spatial requirement.