Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
portland crime mapping
Ruby JavaScript CoffeeScript
branch: master
Failed to load latest commit information.
app fix css on import statistic. doc mongo restart process
autotest use rspec
config bump the schedule up a couple hours. Looks like the city changed the …
db Arson is violent
doc fix css on import statistic. doc mongo restart process
lib nil is reported for crimes with no location now
public restore pictos.css
script initial import
spec updated crime spec
vendor/plugins initial import
.autotest use rspec 2.0 for testing
.gitignore
.rspec use rspec 2.0 for testing
Capfile add capfile and sample mongo db file
Gemfile update mongomapper
Gemfile.lock update mongomapper
README.md
Rakefile initial import
config.ru initial import

README.md

Overview

PortlandCrime is an experiment in crime mapping for Portland, OR. You can see it live at http://portlandcrime.com or http://pdxcrime.com.

Setup

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: http://cloudmade.com/register. Add it to line 20 of public/javascripts/map.js.

Deploying

I run portlandcrime.com on Linode (http://linode.com) and deploy with capistrano. Here is a sample of the configuration I'm using: https://gist.github.com/d683cb464874f4ab33ee.

Assets use Jammit (http://documentcloud.github.com/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.

Demographics

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.