Skip to content

A QGIS plugin that leverages mander to calculate compactness scores of a selection.

License

Notifications You must be signed in to change notification settings

gerrymandr/qgis-compactness

Repository files navigation

QGIS plugin for Compactness Metrics

A work-in-progress at the Metric Geometry and Gerrymandering Group (MGGG).

An open-source plugin built to allow QGIS users to apply different measures of compactness on polygonal features.

  1. Select a layer.
  2. (optional) Select one or more specific features.
  3. Click Compactness Calculations and choose desired metrics.
  4. Choose to save the layer/selection to disk (GeoJSON or Shapefile) and/or add it to your project as an in-memory layer.

Built on top of the Python Mander Library v. 0.3 and 64-bit QGIS 2.18.11

Watch this for an overview on the issues concerning Redistricting, Gerrymandering, and Compactness of Political Districts

Installation

  1. Clone this repository and copy it to your QGIS plugins directory (for example, ~/.qgis2/python/plugins/).
  2. Install mander to your Python environment with eg. [sudo ]pip install mander. Make sure you have GDAL.
  3. Open QGIS and in the Plugins menu click Manage and Install Plugins.
  4. Click Settings and check Show also experimental plugins.
  5. Click All and find the Compactness Calculator plugin and click Install.
  6. Make sure the checkbox is checked and click Close.
  7. You should see a Compactness Calculations menu item in the Vector menu and a button on the toolbar.

(In future) The plugin will be available on the public QGIS plugin repository.

Roadmap

Phase 1: Meet standards for public plugins

  • Confirm duplicate functionality with existing plugins.
  • Link to documentation from inside the plugin.
  • Include a test set.
  • Confirm metadata links are correct.
  • PEP8 compliance and commenting.
  • Rename folder (and repo) to not contain the word plugin.
  • Add external dependencies to "About" metadata field.
  • Create OSGeo account.

Phase 2: Obvious and necessary improvements

  • MultiPolygons - right now only simple polygons are supported.
  • Automatic metric visualization - right now this is up to the user.
  • Instead of hardcoding metrics, can we populate them dynamically from mander?
  • Diagram or tree of how source code files are connected.
  • Custom icon!

Phase 3: Testing and refactoring

  • Unit testing and continuous integration. Relevant blog
  • Can we refactor this to be a subplugin of Processing so it has a lighter footprint and better integration with the rest of QGIS? (eg. modeling, batch commands)

License

Open source, MIT license

Plugin development

Resources

Tutorials

We largely followed this great tutorial.

Plugin Builder has a ton of built in documentation that will describe how to compile and build your plugin. An example is copied here.

  1. In your QGIS plugin directory, compile the resources file using pyrcc4 (simply run make if you have automake or use pb_tool)
  2. Test the generated sources using make test (or run tests from your IDE)
  3. Copy the entire directory containing your new plugin to the QGIS plugin directory (see Notes below)
  4. Test the plugin by enabling it in the QGIS plugin manager
  5. Customize it by editing the implementation file compactness_calculator.py
  6. Create your own custom icon, replacing the default icon.png
  7. Modify your user interface by opening compactness_calculator_dialog_base.ui in Qt Designer

Notes:

  • You can use the Makefile to compile and deploy when you make changes. This requires GNU make (gmake). The Makefile is ready to use, however you will have to edit it to add addional Python source files, dialogs, and translations.
  • You can also use pb_tool to compile and deploy your plugin. Tweak the pb_tool.cfg file included with your plugin as you add files. Install pb_tool using pip or easy_install. See http://loc8.cc/pb_tool for more information.

About

A QGIS plugin that leverages mander to calculate compactness scores of a selection.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published