Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A blank instance of the Newsapps Boundary Service, a point to regional boundary service

branch: master

This branch is 0 commits ahead and 0 commits behind master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 data
Octocat-spinner-32 finder
Octocat-spinner-32 templates
Octocat-spinner-32 .gitignore
Octocat-spinner-32 README.md
Octocat-spinner-32 __init__.py
Octocat-spinner-32 manage.py
Octocat-spinner-32 requirements.txt
Octocat-spinner-32 settings.py
Octocat-spinner-32 settings_override.py.example
Octocat-spinner-32 urls.py
README.md

The Newsapps Boundary Service is a ready-to-deploy system for aggregating regional boundary data (from shapefiles) and republishing via a RESTful JSON API. It is packaged as a pluggable Django application so that it can be easily integrated into any project.

This project allows you to easily create sites like You are here. and Smith County Boundaries.

Getting Started

Follow the instructions in the Python Quick Start Guide to install Homebrew, Git, Python, virtualenv, GDAL and PostGIS.

Create a database using the PostGIS template, replacing boundaryservice with your database's name:

createdb -h localhost boundaryservice -T template_postgis

In the mkvirtualenv command below, replace boundaryservice with your project's name:

mkvirtualenv boundaryservice
git clone git://github.com/opennorth/blank-boundaryservice.git
cd blank-boundaryservice
pip install -r requirements.txt

Configure the DATABASES Django setting and and create the database tables:

cp settings_override.py.example settings_override.py
vi settings_override.py
python manage.py syncdb

You can now copy definitions.py.example to start adding your geospatial data:

cp data/shapefiles/definitions.py.example data/shapefiles/definitions.py

Adding geospatial data

Add your geospatial data to data/shapefiles. It may be a zipfile or a directory containing a shp, shx, dbf, prj. Then, fill in definitions.py. Note that the keys of the SHAPEFILES dictionary and the value of the singular key should be ASCII.

Then, run python manage.py loadshapefiles. Note that this command will import everything under data/shapefiles. If you're already run this command once, then you'll want to specify which data to import. You can include (whitelist) data for import:

python manage.py loadshapefiles -o KeyA,KeyB,...

Or exclude (blacklist) data for import:

python manage.py loadshapefiles -e KeyA,KeyB,...

Important Note: The comma-separated arguments are the keys of the SHAPEFILES dictionary with spaces removed.

If you want to reset the database and start over, run:

python manage.py loadshapefiles -c

If that doesn't work you can always do:

python manage.py sqlreset boundaryservice | psql -h localhost DB_NAME

Development

To test it locally:

python manage.py runserver
curl http://127.0.0.1:8000/1.0/

Customization

To localize the sample boundary sets, etc. edit these two files:

  • Edit EXAMPLE_* in settings_override.py

Deployment

In settings_override.py:

  • configure CACHES
  • set COMPRESS_ENABLED = True
  • set API_DOMAIN

Troubleshooting

If python manage.py runserver quits unexpectedly without error, use an alternative server:

pip install gunicorn
python manage.py collectstatic
gunicorn_django settings.py

If python manage.py loadshapefiles causes this error:

ERROR 1: dlopen(/Library/Application Support/GDAL/1.8/PlugIns/ogr_GRASS.dylib, 1): Symbol not found: __ZN11OGRSFDriver14CopyDataSourceEP13OGRDataSourcePKcPPc
  Referenced from: /Library/Application Support/GDAL/1.8/PlugIns/ogr_GRASS.dylib
  Expected in: flat namespace
 in /Library/Application Support/GDAL/1.8/PlugIns/ogr_GRASS.dylib

you may resolve it on OS X by running:

brew install gdal-grass

If python manage.py loadshapefiles causes this error:

IOError: [Errno 2] No such file or directory: '/var/folders/yn/4cwyp7v55w1c127fbn8sk8gm0000gn/...'

make sure that all files referenced in definitions.py exist.

Contributing

Attribution

This Boundary Service instance uses the following open-source software:

Something went wrong with that request. Please try again.