Sun, S. Developing a Comprehensive and Coherent Shape Compactness Metric for Gerrymandering (forthcoming). Annals of the American Association of Geographers.
R code is under refactoring and coming soon. For working but quite messy code, plase contact me directly.