Skip to main content

Manage political geographic and spatial data, the POLITICO way.

Project description

POLITICO

politico-civic-geography

Manage political geographic and spatial data, the POLITICO way.

Creates a complete set of political geometries as topojson for export to AWS S3 or to interact with in your database.

Read the docs.

Quickstart

  1. Install the app.
$ pip install politico-civic-geography
  1. Add the app to your Django project and configure settings.
INSTALLED_APPS = [
    # ...
    "rest_framework",
    "geography",
]

#########################
# geography settings

CENSUS_API_KEY = ""
GEOGRAPHY_AWS_ACCESS_KEY_ID = ""
GEOGRAPHY_AWS_SECRET_ACCESS_KEY = ""
GEOGRAPHY_AWS_S3_BUCKET = ""
GEOGRAPHY_AWS_REGION = "us-east-1" # default
GEOGRAPHY_AWS_S3_UPLOAD_ROOT = "elections" # default
GEOGRAPHY_AWS_ACL = "public-read" # default
GEOGRAPHY_AWS_CACHE_HEADER = "max-age=3600" # default
GEOGRAPHY_API_AUTHENTICATION_CLASS = "rest_framework.authentication.BasicAuthentication" # default
GEOGRAPHY_API_PERMISSION_CLASS = "rest_framework.permissions.IsAdminUser" # default
GEOGRAPHY_API_PAGINATION_CLASS = "geography.pagination.ResultsPagination" # default
  1. Migrate the database.
$ python manage.py migrate geography

Bootstrapping your database

civic-geography can bootstrap a database of US national, state and county data for you from U.S. Census cartographic boundary files, creating simplified topojson geography. Just run it!

$ python manage.py bootstrap_geography

Use the --help flag to see additional options.

Note: In order to create simplified geography, you must have topojson installed and available via command line on your machine. You can install it via npm.

$ npm install -g topojson

Publishing geography to S3

You can publish your geometries as topojson to an S3 bucket with this command. Give it a state FIPS code to bake out the geometry for that state, or use :code:00 to bake all states.

$ python manage.py bake_geography 00

Developing

Running a development server

Move into the example directory, install dependencies and run the development server with pipenv.

$ cd example
$ pipenv install
$ pipenv run python manage.py runserver
Setting up a PostgreSQL database
  1. Run the make command to setup a fresh database.
$ make database
  1. Add a connection URL to example/.env.
DATABASE_URL="postgres://localhost:5432/geography"
  1. Run migrations from the example app.
$ cd example
$ pipenv run python manage.py migrate
Developing the docs

Within a pipenv shell, navigate to the docs directory and run the docs development server.

$ make livehtml

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

politico-civic-geography-1.0a2.dev1.tar.gz (1.2 MB view details)

Uploaded Source

Built Distribution

File details

Details for the file politico-civic-geography-1.0a2.dev1.tar.gz.

File metadata

  • Download URL: politico-civic-geography-1.0a2.dev1.tar.gz
  • Upload date:
  • Size: 1.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.16

File hashes

Hashes for politico-civic-geography-1.0a2.dev1.tar.gz
Algorithm Hash digest
SHA256 9b261bbc4cda24bb24641a368626555e230f289ced3694d41218b3dba6bd0595
MD5 706b958c2641212956d90e20ac53ee16
BLAKE2b-256 27ed52e4a49195772f95ad2a17c0e053f1b1d6ac5c65cc90ebc88c5547cca82a

See more details on using hashes here.

File details

Details for the file politico_civic_geography-1.0a2.dev1-py2-none-any.whl.

File metadata

  • Download URL: politico_civic_geography-1.0a2.dev1-py2-none-any.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.16

File hashes

Hashes for politico_civic_geography-1.0a2.dev1-py2-none-any.whl
Algorithm Hash digest
SHA256 81b137b0a5c574e86a65e959f5a1b4e5a3a6a7091200258ff3e8813d49ce8b21
MD5 a3650a19b0626a582c566f6f51dbc8b5
BLAKE2b-256 dfed8cd3a7278981681c5b173eb70d7beea9554f848899b432dd8f812c9d3bac

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page