Abstract
The QGIS ‘Polygon Divider’ plugin solves the problem of partitioning an arbitrarily complex polygon into an irregular grid of equal area rectangles, which has a range of applications for city science and GIS more broadly. This is achieved by the iterative partition of the polygon using cutlines that are located using Brent’s method, which is an efficient optimisation algorithm. At the time of release, this was the only tool with such functionality in a major GIS platform, though the functionality has since been replicated.
Introduction
Polygon partitioning (i.e. subdivision based on some geometric criteria) is a popular topic in computational geometry, with common examples including triangulation (partitioning into triangles) and monotonic decomposition (partitioning into a set of monotonic polygons) (De Berg et al., 2008). This research presents an algorithm to partition an arbitrarily complex polygon into an irregular grid of equal area rectangles (i.e. ‘equipartition’ into an irregular rectangular grid). The user can specify either the desired cell area, or the desired number of cells, which simply comprises partitioning into cells of size
Equipartition is an active area of research, though is rarely discussed in the context of city science or GIS applications. Existing applications in the literature are limited to the partition of convex polygons (e.g. Armaselu and Daescu, 2015; Guàrdia and Hurtado, 2005); or require that the partitions are connected to the polygon boundary (as in slicing a pizza; e.g. Abrahamsen and Rasmussen, 2025; Blagojević and Ziegler, 2014). Neither of these limitations are acceptable for GIS or city science applications. An alternative approach for equipartition into an irregular grid uses a point placement algorithm called ‘Lloyd’s Relaxation’ (Deussen, 2009). This method constructs Voronoi polygons around a set of random points within the polygon, and then iteratively optimises the point locations to equalise the polygon areas (Campillo et al., 2024). However, the reliance on Voronoi polygons means that the polygon boundary is not preserved, as can be seen in Wood (2022), which again is unacceptable for most GIS applications.
At the time that the plugin was created, this functionality was not available in any major GIS software or library. A similar solution for polygon partition subdivision based on cutline optimisation using Brent’s method had previously been implemented for ArcView 3.x by William Huber, but this also required that partitions are connected to the polygon boundary (as in slicing a loaf of bread). This tool is no longer available, though a description of the approach in an online forum provided the basis for the approach taken here (Huber, 2011). Since the release of the QGIS plugin, a similar tool has been added to ArcGIS Pro, but the documentation gives no explanation of the algorithm (ESRI, 2024).
Algorithm description
The plugin can be installed from the official QGIS plugin repository using the QGIS Plugin Manager. To operate the plugin, the user simply uses the dialogue to set the input and output files, desired target area or number of divisions, cut direction (left to right, top to bottom, right to left, and bottom to top), tolerance (how close each polygon can be to the desired area), rotation (of the grid axes relative to the polygon), and whether ‘offcuts’ should be divided and absorbed into the partitions or left as a separate polygon. For example, if a user required to divide a polygon of 104 m2 into subdivisions of 25 m2, then the result could be either 4 polygons of 26 m2 (where the ‘Absorb Offcuts’ checkbox is checked), or 4 polygons of 25 m2 plus one ‘offcut’ of 4 m2 (where it is un-checked). The user dialogue is shown in Figure 1. The dialogue window for the QGIS Polygon Divider Plugin.
The proposed method requires that the input polygon(s) must be projected using a two-dimensional Cartesian ( Diagram illustrating the algorithm.
To achieve the above, the first task is to determine the target area of the initial ‘slice’. The side length of a square of area An illustration of the approach to equipartition into an irregular rectangular grid, whereby (a) a large ‘slice’ is first extracted, and then (b) is further divided into polygons of the desired area (with the cut direction perpendicular to that in a).
Equipartition is achieved by optimising the location of a cutline that is used to split the polygon. The optimisation technique is Brent’s method (1971), which is a function rooting algorithm: for a given function
However, the IQI method will fail if it encounters two equal values within its three points (e.g.
To apply Brent’s method to polygon subdivision, the function parameter (
where (a) An illustration of the construction of a cutline moving from the bottom of the polygon. (b) The results of the QGIS Polygon Divider Plugin, equipartitioning the boundary of Gulu District (Uganda) into an irregular rectangular grid of 100,000 km2 cells. (c) The results of the same division with a 45° rotation.
Brent’s method is guaranteed to converge for functions that are computable within the interval of the two initial points (Brent, 2013). However, this condition is not necessarily met in the case of an arbitrarily complex polygon, as the relationship between the cutline coordinate and area can behave in a non-continuous manner in some geometries. One example of this can be illustrated by a horizontal cutline progressing downward from the top-left end of a ‘W’ shaped polygon (Figure 5). As the cutline passes the point in Figure 5(a), the area of the subdivision instantaneously increases (Figure 5(b)), resulting in a non-continuity in the function meaning that it does not intersect the x-axis, and hence has no root. This situation is resolved by simply changing the cut direction and resuming the partition operation, which allows the method to complete successfully. As the cutline moves from location 
The efficiency of this method is a composite of the cost of the function evaluation, which is
Conclusion
The algorithm was originally developed in support of a national methodology for litter monitoring in urban areas in Scotland (Zero Waste Scotland, 2018b), which is a legal requirement for UK duty bodies (e.g. local authorities) and statutory undertakers (e.g. railway operators) (UK Government, 1990; Zero Waste Scotland, 2018a). The software is used to partition all eligible land into 1000 m2 zones, which are then classified and a subset selected for ongoing monitoring using a grading system (Zero Waste Scotland, 2018b). Other research applications of the algorithm in the urban planning literature includes analysis of transport accessibility (Wang et al., 2019), greenspace exposure (Labib et al., 2021), and urban habitat restoration (Boncourt et al., 2024). Given that the problem of polygon equipartition into an irregular grid is relatively fundamental to GIS, it has also found research applications beyond city science, including habitat diversity (Fernández-García et al., 2021), ecology (Huylenbroeck et al., 2021), and sustainable forestry planning (Picchio et al., 2020). Future developments will explore the potential to improve the efficiency of the algorithm, for example, through the use of alternative approaches to Brent’s method (e.g. replacing IQI with using hyperbolic extrapolation, Bus and Dekker, 1975), or alternative approaches to function rooting (e.g. Ridders, 1979).
Footnotes
Acknowledgements
The impetus for the creation of this tool came from my good friend Roy Ferguson. Financial support for the initial development of the plugin (for QGIS 2. x) was provided by Zero Waste Scotland Ltd. and for the upgrade to QGIS 3. x by Deutsche Forestservice GmbH. It has also been improved by feedback, suggestions, and contributions from other QGIS/GitHub users. The implementation of Brent’s method is a modified version of that provided in the pyroots library, which is released under the BSD license (
). As described above, the approach taken in this software owes a great deal to the original idea and description provided by William Huber.
Funding
The author(s) disclosed receipt of the following financial support for the research, authorship, and/or publication of this article: This work was supported by the Zero Waste Scotland Ltd; Deutsche Forestservice GmbH.
Declaration of conflicting interests
The author(s) declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.
Data Availability Statement
The QGIS Polygon Divider is available for download in the QGIS Polygon Repository (https://plugins.qgis.org/plugins/Submission/). The source code is available on GitHub (
) and issues (including suggestions and feature requests) can be raised at the same location.
