Skip to content
portland crime mapping
Ruby JavaScript CoffeeScript
Find file


PortlandCrime is an experiment in crime mapping for Portland, OR. You can see it live at or


Requires Ruby 1.9.2 and MongoDb

  1. Create DB & load offenses: rake db:seed
  2. Import crime: rake crime:import. This will import the current year, providing YEAR=2009 rake crime:import.
    You should at least import this year and last year.
  3. Run reports:

    rake crime:reports:all
  4. Import trimet stops and routes:

    rake trimet:import:routes  # Import Trimet Bus, Max, and Streetcar Routes
    rake trimet:import:stops   # Import Trimet Bus, Max, and Streetcar Stops
  5. (And I apologize for this) Run Migration to import Neighborhood geo data and normalize names:

    rake migrations:one_normalize_neighborhood_names
    rake migrations:four_flag_non_portland_neighborhoods
  6. Get a CloudMade API key: Add it to line 20 of public/javascripts/map.js.


I run on Linode ( and deploy with capistrano. Here is a sample of the configuration I'm using:

Assets use Jammit ( which is great for compression.

Check out config/schedule.rb for a sweet ruby DSL to cron that run reports.

The library that generates visualizations is pretty hefty, so it's a VERY good idea to precache assets with Jammit and use Nginx's gzip_static module. It's the single best thing you can do to increase page load times.


There are neighborhood demographics in db/data/neighborhood-demographics.csv and supporting models for those demographics, however, I found them to be outdated and questionable so I chose not to use them. I've asked the city about updating these statistics and was informed that they haven't received budget approval for such a project, but they gave me the census block data they used to correlate neighborhoods to census blocks. I hope I can use this data to upgrade neighborhood demographics for the new American Community Survey.

If you want to import demographics anyway, run rake migrations:three_import_neighborhood_demographics

Something went wrong with that request. Please try again.