| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A Python package and command line utility for calculating compactness metrics of electoral districts.
What scores are available?
import mander
mander.getListOfScores()Getting scores for GeoJSON:
import mander
geojson_data = """{ "type": "FeatureCollection", "features": [{"type": "Feature","properties": {},"geometry": { "type": "Polygon", "coordinates": [ [ [ -30.585937499999996, 27.68352808378776 ], [ -2.8125, 27.68352808378776 ], [ -2.8125, 46.800059446787316 ], [ -30.585937499999996, 46.800059446787316 ], [ -30.585937499999996, 27.68352808378776 ] ] ] } } ] }"""
mander.getScoresForGeoJSON(geojson_data)Augmenting an existing shapefile with compactness scores:
import mander
mander.augmentShapefileWithScores("us_electoral_districts.shp")Compactness scores are calculated using the underlying compactnesslib a list of the scores available and how they are calculated is available here.
Fork this repo
Clone your fork
git clone git@github.com:YOUR_USERNAME_HERE/python-mander.git
Add the original repo as a remote
git remote add upstream git@github.com:gerrymandr/python-mander.git
This project depends upon a C++ library sourced from a git submodule. Initialize and update the git submodule.
git submodule init git submodule update
Optionally create and activate a Python virtual environment. On Linux or Mac
virtualenv env source env/bin/activate
On Windows
virtualenv env env\Scripts\activate
On any platform, you may exit the virtual environment by running
deactivate
Install the dependencies
pip install -r requirements.txt
Build the project
python setup.py build
CC=gcc-7 python setup.py build
This package was created for the Metric Geometry And Gerrymandering Group as part of a hack-a-thon on August 10-11, 2017.
| Back | FazBrowse Home | New Git URL |