No description or website provided.
Python Shell
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



This is a Django app that was generated by running paster create -t openblock openrural. It starts as a thin wrapper around ebpub, and like any such django app it may be customized by adding templates, modifying, etc.

For more documentation, see

For deployment with apache's mod_wsgi, there is a suitable wsgi script in the wsgi/ directory.

There are more example config files in etc/.

Local Development Setup

Clone Open Rural and create a new virtualenv:

$ git clone git://
$ cd openrural-nc/
$ mkvirtualenv --distribute -p python2.6 openrural

If you're on Ubuntu 11.04, install GDAL the hard way. The commands are:

$ gdal-config --version
$ pip install --no-install "GDAL>=1.6,<1.7a"  # adjust version as needed
$ rm -f $VIRTUAL_ENV/build/GDAL/setup.cfg
$ cd $VIRTUAL_ENV/build/GDAL
$ python build_ext --gdal-config=gdal-config \
                            --library-dirs=/usr/lib \
                            --libraries=gdal1.6.0 \
                            --include-dirs=/usr/include/gdal \

Install the OpenRural packages:

$ cd openrural-nc/
$ pip install -r requirements/deploy.txt
$ pip install --no-index \
              --find-links=file:$PWD/requirements/sdists/ \
              -r requirements/ebdata.txt \
              -r requirements/ebpub.txt \
              -r requirements/obadmin.txt \
              -r requirements/openrural.txt
$ add2virtualenv .

If you're developing OpenBlock, you should install the development version:

$ mkvirtualenv --distribute -p python2.6 openrural
$ pip install -r requirements/deploy.txt
$ fab develop:../openblock,no_index=True
$ pip install -r requirements/dev.txt
$ add2virtualenv .

Create a PostgreSQL database for development:

$ createdb --template=template_postgis openblock_devel

Create a local settings file:

$ cp openrural/ openrural/

Edit and extend from the project settings module you want to work on:

< from openrural.settings import *
> from openrural.settings_whiteville import *

Point Django do your local settings and initialize the database:

$ export DJANGO_SETTINGS_MODULE=openrural.local_settings
$ syncdb --migrate

If everything went smoothly, you can now runserver:

$ runserver

Columbus County, NC

To import data for Columbus County, NC:

$ import_nc_zips
$ import_county_streets 37047
$ import import_columbus_county

Where 37047 is the U.S. Census county ID for the county you want to import (37047 = Columbus County, NC).

Orange County, North Carolina

For example, to import data for Orange County:

$ import_nc_zips
$ import_county_streets 37135
$ import_location_zip
$ wget -O; \
  unzip -d city; \
  rm; \
  import_locations --type-name=City --type-name-plural=Cities cities ./city/; \
  rm -rf ./city
$ wget -O; \
  unzip -d townships; \
  rm; \
  import_locations --type-name=Township --type-name-plural=Townships townships ./townships/; \
  rm -rf ./townships

Install ZIP codes Manually

We'll use the U.S. Census Bureau TIGER/Line data for North Carolina, specifially 23MB of 5-Digit ZIP Code Tabulation Area (2002):

$ wget
$ unzip -d zipcodes
$ import_zips_tiger -v -b zipcodes/

Importing Streets Manually

Now we'll get the block data, including Columbus County data:

You can import these like so:

$ wget \ \ \
$ unzip -d blocks \*.zip
$ import_blocks_tiger --city=WHITEVILLE \
                      --filter-bounds=1 \
                      blocks/tl_2009_37047_edges.shp \
                      blocks/tl_2009_37047_featnames.dbf \
                      blocks/tl_2009_37047_faces.dbf \

Derive streets and intersections from the blocks data:

$ populate_streets -v -v -v -v streets
$ populate_streets -v -v -v -v block_intersections
$ populate_streets -v -v -v -v intersections

Configure Database Logger

To log debugging information to the database for later analysis, you can use the DatabaseHandler with specific loggers:

    'handlers': {
        'database': {
            'level': 'DEBUG',
            'class': 'openrural.error_log.logger.DatabaseHandler',
    'loggers': {
        'ebpub.streets.blockimport': {
            'handlers': ['database',],
            'level': 'DEBUG',

This will, of course, slow down any intensive operation as it is continually interacting with the database.