Skip to content

OpenData-NC/openrural-nc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenRural

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 urls.py, etc.

For more documentation, see http://openblockproject.org/docs/install/custom.html

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://github.com/openrural/openrural-nc.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
1.6.3
$ 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 setup.py build_ext --gdal-config=gdal-config \
                            --library-dirs=/usr/lib \
                            --libraries=gdal1.6.0 \
                            --include-dirs=/usr/include/gdal \
                            install

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/local_settings.py.example openrural/local_settings.py

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

1c1
< 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
$ django-admin.py syncdb --migrate

If everything went smoothly, you can now runserver:

$ django-admin.py runserver

Columbus County, NC

To import data for Columbus County, NC:

$ django-admin.py import_nc_zips
$ django-admin.py import_county_streets 37047
$ django-admin.py 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:

$ django-admin.py import_nc_zips
$ django-admin.py import_county_streets 37135
$ django-admin.py import_location_zip http://web.co.orange.nc.us/gisdownloads/city.zip
$ wget http://web.co.orange.nc.us/gisdownloads/city.zip -O city.zip; \
  unzip -d city city.zip; \
  rm city.zip; \
  import_locations --type-name=City --type-name-plural=Cities cities ./city/; \
  rm -rf ./city
$ wget http://web.co.orange.nc.us/gisdownloads/townships.zip -O townships.zip; \
  unzip -d townships townships.zip; \
  rm townships.zip; \
  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 http://www2.census.gov/geo/tiger/TIGER2009/37_NORTH_CAROLINA/tl_2009_37_zcta5.zip
$ unzip tl_2009_37_zcta5.zip -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 http://www2.census.gov/geo/tiger/TIGER2009/37_NORTH_CAROLINA/tl_2009_37_place.zip \
       http://www2.census.gov/geo/tiger/TIGER2009/37_NORTH_CAROLINA/37047_Columbus_County/tl_2009_37047_edges.zip \
       http://www2.census.gov/geo/tiger/TIGER2009/37_NORTH_CAROLINA/37047_Columbus_County/tl_2009_37047_faces.zip \
       http://www2.census.gov/geo/tiger/TIGER2009/37_NORTH_CAROLINA/37047_Columbus_County/tl_2009_37047_featnames.zip
$ 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 \
                      blocks/tl_2009_37_place.shp

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:

LOGGING = {
    '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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published