Fetching contributors…
Cannot retrieve contributors at this time
75 lines (43 sloc) 3.38 KB

The Newsapps Boundary Service

The 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.

Open source examples of implementing the boundary service:


Using pip:

$ pip install django-boundaryservice

Add the following to INSTALLED_APPS in your

... 'tastypie', 'boundaryservice', ...

Add the following to your

(r'', include('boundaryservice.urls')),

Adding data

To add data you will first need to add a shapefile and its related files (prj, dbf, etc.) to the data/shapefiles directory. Shapefiles and your go into this folder. See the hacktyler demo site for a complete example.

If you havn't already, you can create your definitions file using a management command:

$ python startshapedefinitions

You can load all definitions like so:

$ python loadshapefiles

You may also override the default location by passing the "-d" flag to the command or setting SHAPEFILES_DIR in

$ python loadshapefiles -d data_dir

You can load only a specified shapefile with the "-o" flag:

$ python loadshapefiles -o ShapeFileName

You can clear a particular shapefile from the database and reload it with the "-c" flag:

$ python loadshapefiles -c ShapeFileName



Of particular note amongst the defintion fields are the 'ider' and 'namer' properties. These should be assigned to functions which will be passed a feature's attributes as a dictionary. 'ider' should return a unique external id for the feature. (e.g. a district id number, geographic id code or any sequential primary key). Whenever possible these ids should be stable across revisions to the dataset. 'namer' should return a canonical name for the feature, not including its kind. (e.g. "Austin" for the Austin Community Area, "Chicago" for the City of Chicago, or #42 for Police Beat #42) A number of callable classes are defined in data/shapefiles/, which should mitigate the need to write custom functions for each dataset.


As a matter of best practice when shapefiles have been acquired from government entities and other primary sources it is advisable not to modify them before loading them into the Boundary Service. (Thus why the Chicago neighborhoods shapefile is misspelled "Neighboorhoods".) If it is necessary to modify the data this should be noted in the 'notes' field of the shapefile's entry.


The Boundary Service is a product of the News Applications team at the Chicago Tribune. Core development was done by Christopher Groskopf and Ryan Nagle.