plugin_measures_of_compactness

QGIS Measures of compactness expressions plugin

This plugin adds some common ways to measure the degree of compactness of a geometry(ies) (Polsby–Popper, Reock, Skew, etc…). These functions are added as part functions expression that works in the context of the field calculator in QGIS

These functions are particularly useful to detect gerrymandering, evaluate the regularity of a parcel, lot, etc…

For an introduction on geometry and compactness, see the wonderful Math for the people course https://web.stevenson.edu/mbranson/m4tp/version1/gerrymandering-math-topic-compactness.html

And for a visual representation of these functions see https://fisherzachary.github.io/public/r-output.html

Report an issue here : https://github.com/ValentinBuira/plugin_measures_of_compactness/issues

How to use

The expressions functions of plugin are all located in the field calculator window under the “Compactness” sub menu

Screenshot of where are the expressions function add in the field calcultor

Reference

This section give an overview of the functions in the plugin. For a more complete explanation how they work please refer to the “in-line” documentation direclty inside QGIS.

compactness_pp : Polsby-Popper compactness

Calculate a Polsby-Popper(PP) compactness score

The Polsby-Popper (polsby & Popper, 1991) is the ratio of the area(A) of the geometry to the area of a circle whose circumference is equal to the perimeter(P) of the geometry.

Can be written as:

4 * pi * (A / P*P )  * Where *A* is the area of the geometry  * Where *P* is the perimeter of the geometry 

Scores range from 0 to 1, where 0 is the least compact and 1 is the most compact.

exemple usage : compactness_pp( $geometry )

compactness_skew : Skew compactness

Calculate a skew compactness

A skew compactness compares the area of the maximum inscribed circle (A_mic) to the area of the minimum bounding circle (A_mbc).

Scores range from 0 to 1, where 0 is the least compact and 1 is the most compact.

exemple usage : compactness_skew( $geometry )

Note: only available on QGIS >=3.42

compactness_reock: Reock Compactness

Calculate a reock compactness

A reock compactness is the ratio between the area (A) of the geometry to the area of the minimum bounding circle (A_mbc)

Scores range from 0 to 1, where 0 is the least compact and 1 is the most compact.

exemple usage : compactness_reock( $geometry )

compactness_box_reock: Box Reock Compactness

Calculate a box reock compactness

A box reock compactness is the ratio between the area (A) of the geometry to the area of the minimum bounding box (A_bbox)

Scores range from 0 to 1, where 0 is the least compact and 1 is the most compact.

exemple usage : compactness_box_reock( $geometry )

compactness_schwartz: Schwartzberg Compactness

Calculate a schwartzberg compactness

Can be written as:

S = 1 / (P / (2pi * sqrt(A / pi))) * Where A is the area of the geometry  * Where P is the perimeter of the geometry 

Scores range from 0 to 1, where 0 is the least compact and 1 is the most compact.

exemple usage : compactness_schwartz( $geometry )

compactness_lw: Length-Width Compactness

Calculate a Length-Width Compactness

Length-Width compactness compares the width and the length of a a geometry using its bouding box

Scores range from 0 to 1, where 0 is the least compact and 1 is the most compact.

exemple usage : compactness_lw( $geometry )

Thanks

This plugin was heavily influenced by the redistmetrics R package made by the ALARM projects see also https://cran.r-project.org/web/packages/redistmetrics/vignettes/compactness.html as a complementary documentation

And to whoever wrote guide that make theses compactness measures easy to understand visually https://fisherzachary.github.io/public/r-output.html