Skip to content

An interactive web map of the New Zealand Transport Agency's Crash Analysis System (CAS) data.

License

Notifications You must be signed in to change notification settings

caffeineinc/national-crash-statistics

 
 

Repository files navigation

NZTA's Crash Analysis System (CAS)

An interactive web map of the New Zealand Transport Agency's Crash Analysis System (CAS) data, representing all accidents that have been attended by police, given a location, and that we have chosen to present (based on currency).

Take me to the map

Made with Python (to read the raw CSVs and produce a nice GeoJSON with useful filters and attributes to build the popups) and Leaflet (to display the GeoJSON on the map).

An early version was featured on the NZ Herald data blog and was the most read article Christmas Day 2014

Acknowledgements

  • Chris Hewitt (NZTA), for early feedback and a "go ahead"
  • Tom Pettit (Wellington City Council; New Zealand Centre for Sustainable Cities) for support and feedback
  • The NZTA, for publishing this data in a largely machine-readable format
  • Harkanwal Singh, the New Zealand Herald Data Editor, for featuring the map.

Want to contribute?

Please, feel absolutely free. The data is open, and so is this. Get the map working on your local computer with the following terminal commands:

cd /path/to/directory/
git clone https://github.com/alpha-beta-soup/national-crash-statistics

If you have Python2, then run

python -m SimpleHTTPServer 8000

If you have Python3:

python3 -m http.server 8000

The navigate to http://localhost:8000/ in your browser to have a look at the map. This is how you can preview any changes you make.

Requirements:

cd /tmp/
git clone https://github.com/jswhit/pyproj.git 
cd pyproj
python setup.py build
sudo python setup.py install
cd /tmp/
wget https://pypi.python.org/packages/source/g/geojson/geojson-1.0.9.tar.gz#md5=94880d993dba8b184de122c5a84fa329
gunzip geojson-1.0.9.tar.gz | tar -xopf geojson-1.0.9.tar
cd geojson-1.0.9
python setup.py build
sudo python setup.py install

The basic structure is as follows:

  • nzta2geojson.py creates the file data.geojson that represents the location of each crash. Its properties are what the filters look for (e.g. alcohol = true will give you all accidents where alcohol was a listed "role or factor" in the accident). The Python script is what performs these checks, once, before writing the output. This is executed with cd source/ && python nzta2geojson.py.
  • nzta-crash-analysis.js is the Javascript script that creates the Leaflet map and uses JQuery for the filtering proceedure.
  • index.html and nzta-crash-analysis.css represent the structure of the webpage and the styling of the various elements.

There is no database, just a static file. We know that's not ideal, and are looking to scale up in the future (perhaps you can help out). When we do, we'll be able to present all 14 years' of data that is available to the public, as opposed to the 7 months' worth we show now.

Other ways to help out include designing (or re-designing if you're angry) the icons that appear in the pop-ups, or giving us feedback on what does and doesn't work so well.

We'd also love to make some interactive charts of the information, because a map doesn't even reveal the most interesting patterns that undoubtedly exist in a dataset of this nature.

About

An interactive web map of the New Zealand Transport Agency's Crash Analysis System (CAS) data.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 45.2%
  • Python 43.2%
  • HTML 7.1%
  • CSS 4.5%