Skip to content
Lord of the Rings themed pedestrian routing app that returns custom routes based on San Francisco crime data
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
There and Back Again DB Table Design.pdf

There and Back Again

With its Lord of the Rings inspired UI, There and Back Again delivers walking routes to pedestrians in SF that avoid high crime areas. The app uses a branch of OSRM as its routing engine, which returns the optimum route based on a custom routing profile. This profile weights graph edges using a rasterized crime data set. Users can also view a heat map of crime near their route, as well as a chart that illustrates how the crime density of the route varies throughout the route. There and Back Again Homepage

There and Back Again is a web app created by Amanda Meurer. Amanda is passionate about using big data to influence everyday decisions. She set out to create the ultimate pedestrian routing app. This repository is the result of several weeks' work, and weights routes based on crime densities in San Francisco. In the future Amanda hopes to pull in more datasets (elevation, lighting, construction, coffee shop locations, etc) to craft the optimum walking experience for any user. She would also like to make a mobile app version.

Table of Contents

Technologies Used

  • Python
  • C++
  • LUA
  • OSRM (Open Source Routing Machine)
  • Flask
  • numpy
  • PostgresSQL/PostGIS
  • GeoAlchemy/SQLAlchemy
  • Javascript/jQuery
  • Jinja2
  • Chart.js
  • polyline.js
  • Bootstrap
  • MapBox API
  • Google Maps API

(dependencies are listed in requirements.txt)

How to locally run There and Back Again

There and Back Again has not yet been deployed, so here is how to run the app locally on your machine.

###Run your own instance of OSRM Use this branch of OSRM:

  • Set up your C++ dependencies
    • source ./
  • Compile your source
    • source ./
  • Run OSRM
    • "Running OSRM" is here However, this is exactly what you need to do for There and Back Again:
    • osrm-extract san-francisco_california.osm.pbf -p profiles/foot_crime.lua (the *.osm.pbf file is downloaded from here)
    • osrm-prepare san-francisco_california.osrm -p profiles/foot_crime.lua
    • osrm-routed san-francisco_california.osrm -- this command is what will actually start your server, as long as the last two steps were successful; you can now go to localhost:5000/viaroute?… as described here

Run the There and Back Again Flask App

  • Set up and activate a python virtualenv, and install all dependencies:
    • pip install -r requirements.txt
  • Make sure you have PostgreSQL running. Create a new database in psql named lotr:
    • psql
  • Create the tables in your database:
    • python -i
    • While in interactive mode, create tables: db.create_all()
    • Seed the crimes table with crime latitudes and longitudes: CrimePoints.seed_points()
  • Now, quit interactive mode. Start up the flask server:
    • python
  • Go to localhost:9000 to see the web app

How to use There and Back Again

###Enter starting point and destination, then click Find a Path Two routes will appear on the map. The red route is the regular walking route returned by the MapBox Directions API. The golden route is the custom route returned from OSRM that routes the pedestrian around paths with high crime density.

The walking directions will also slide down at this time.

There and Back Again Route and Directions

###Press the Generate Heat Map button This button will query the database for all the crime occurrences in the bounding box of the current route. It will display these points as a heat map overlaying the map. Press 'Hide Heat Map' to make the heat map go away.

There and Back Again Heat Map

###Press the View Crime Density Graph button This button will query the database for all points within 5 meters of the safe route, and represent that data as a graph to the user. This graph shows the user how the crime density changes throughout the course of their journey.

There and Back Again Graph


Amanda Meurer is a software engineer in San Francisco, CA.

You can’t perform that action at this time.