GithubHelp home page GithubHelp logo

mysociety / collideoscope-heatmap Goto Github PK

View Code? Open in Web Editor NEW
0.0 4.0 0.0 57 KB

Geoprocessing script for generating collision heatmap on Collideoscope.

Home Page: https://www.collideoscope.org.uk/

Python 93.42% Dockerfile 3.17% Makefile 3.41%

collideoscope-heatmap's Introduction

collideoscope-heatmap

Script to generate the geopackage used for the Collideoscope heatmap (which originated here).

Heatmap screenshot

The geopackage is generated by combining road features from OS Open Road shapefiles with the points of all incidents in the Collideoscope database. Each feature in the output has a density attribute which represents the number of incidents per metre along the feature. Only road features with >1 incident (total) are included.

Quickstart

The simplest way to generate the geopackage is to use the Makefile to get you up and running quickly. Requires Docker and read-only access to the Collideoscope Postgres database.

$ export COLLIDEOSCOPE_DATABASE_URL="postgres://user:password@postgreshost:5432/collideoscope"
$ curl https://raw.githubusercontent.com/mysociety/collideoscope-heatmap/master/Makefile | make -f - heatmap

This takes an hour or so to run, and will generate heatmap.gpkg in the current directory.

Running via Docker

You gain more control over the behaviour of the script by invoking docker run manually. For example if you already have OS Open Roads downloaded locally to $HOME/Downloads and want to use that, and want the heatmap stored somewhere other than the current directory:

$ export COLLIDEOSCOPE_DATABASE_URL="postgres://user:password@postgreshost:5432/collideoscope"
$ docker run \
    -e COLLIDEOSCOPE_DATABASE_URL \
    -e OS_OPEN_ROADS_PATH=/input/oproad_essh_gb.zip \
    -e OUTPUT_PATH=/output/collideoscope.gpkg \
    -v /data/library/mapserver:/output \
    -v ${HOME}/Downloads:/input \
    -t davea/collideoscope-heatmap

Running locally

The script uses pipenv for virtualenv management, so install that if you haven't already. Then, run the script:

$ cat .env
COLLIDEOSCOPE_DATABASE_URL=postgres://user:password@postgreshost:5432/collideoscope
$ pipenv install
$ pipenv run python generate_heatmap.py

collideoscope-heatmap's People

Contributors

davea avatar

Watchers

 avatar James Cloos avatar Sam Pearson avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.