MinnPost Crime
An application that explores crime in Minnesota, specifically Minneapolis. The live application can be found at minnpost.com/crime.
Updating data
Crime data comes from monthly reports produced by the Minneapolis PD. Due to the files being removed once, we upload the files to S3 so that we have our copy of the original data if needed. We then use ScraperWiki to store the data for us.
- Download newest Excel file from the MPD site.
- Rename to
YYYY-MM.xlsx
, for example2014-06.xlsx
. - Inspect Excel file and make sure the following.
- The file is an
.xlsx
or.xls
file. Both can be handled, but the former needs to be noted in the Scraper entry. - The first tab is the month. There will probably be other tabs for year-to-date, or quarterly data.
- There are 10 columns, one for the neighborhood and the rest for stats.
- There is only one line for the headers. This can be handled in the scraper if needed as well.
- There are no empty lines before the last line. This can be handled in the scraper if needed as well.
- The file is an
- Upload to AWS S3 in the following location:
data.minnpost/projects/minnpost-crime/data-source/mpls-monthly-reports
- Make the item Public. This can be done by right-clicking the item and selecting
Make Public
. - Use the
Properties
tab in the S3 interface to copy the URL to the new item.
- Make the item Public. This can be done by right-clicking the item and selecting
- Update the crime data scraper on ScraperWiki.
- Towards the end of the code, add an entry to the configuration dictionary. It should look like the most recent one. If some of the aspects (see above) of the file are not usual, you can provide some config for that; check out some of the older files.
year
month
url
: This is the URL to the file on S3original
: This is not used at all and just for reference, but should be the URL to the file on the MPD site.
- Double check your code.
- Run the scraper. It should only run the most recent entry that you added; if you run again, it will end up processing all the files and this will take some time.
- Check the output and make sure there are no errors (there may be a warning about HTTPS, but this seems to be fine)
- Towards the end of the code, add an entry to the configuration dictionary. It should look like the most recent one. If some of the aspects (see above) of the file are not usual, you can provide some config for that; check out some of the older files.
- Wait an hour or (optional) Clear the data proxy. There is a proxy on Heroku that caches some of the ScraperWiki data and protects against ScraperWiki going down (which only happened once).
- Make sure that you have access to the MinnPost Heroku account and have Heroku setup on your computer.
- Get the proxy code from Github
- Connect code to Heroku:
heroku git:remote -a all-good-proxy
- Restart app:
heroku restart
- Check the dashboard
Development and Install
Perquisites
- Install Git. On Mac with Homebrew:
brew install git
- Install NodeJS. On Mac with Homebrew:
brew install node
- Install Grunt:
npm install -g grunt-cli
- Install Bower:
npm install -g bower
- Install Sass:
gem install sass
- Because Leaflet comes unbuilt, we need to build it with Jake:
npm install -g jake
Get the code
- Clone the repository with something like:
git clone git@github.com:MinnPost/minnpost-crime.git
- Go into the code directory:
cd minnpost-crime
Install libraries
npm install
bower install
- Because Leaflet comes unbuilt, we need to build it:
cd bower_components/leaflet/ && npm install && jake; cd -;
Run
- Us grunt to watch files for changes and serve the files with:
grunt server-watch
- Go to localhost:8899/index.html in your browser.
Build
grunt
Deploy
grunt mp-deploy
Data processing
- To turn MN Compass neighborhood profile data to JSON:
node data-processing/mncompass-2010-xlsx-json.js
- Create final Minneapolis neighborhood data JSON:
- Run:
node data-processing/minneapolis-neighborhoods.js
- Run:
Data
Minneapolis
Crime
- Scraper of Minneapolis Monthly Reports. Original reports can be found on the MPD stats page. These reports are very similar to the FBI Uniform Crime Reports, except that they use the date of the offense (not reported date) and count each offense of the report (not the worse offense) see details.
- (not applicable anymore) Due to the fact that the MPD has decided not to release Excel files anymore. This means that PDF's are manually parsed with Tabula and put into the
data/crime/mpls-monthly-reports-manual-folder
. These are then uploaded to S3 and used in the scraper. - Run
node data-processing/download-mpls-monthly-reports.js
to download the existing Excel files locally. Then dogrunt mp-source-data
to upload these files to S3.
- (not applicable anymore) Due to the fact that the MPD has decided not to release Excel files anymore. This means that PDF's are manually parsed with Tabula and put into the
Demographics
- MN Compass has a zipped Excel file of demographic data for Twin Cities neighborhoods that is downloaded here for processing. This is mostly 2010 population data with 2005-2009 employment and related data.
- The City of Minneapolis has a 2000 race and ethnicity report. A scraper of this data has been made. Download with:
wget -O data/demographics/2000/minneapolis-demographics-2000.json "https://api.scraperwiki.com/api/1.0/datastore/sqlite?format=json&name=minneapolis_neighborhood_census_population_2000&query=select%20*%20from%20%60swdata%60"
- Note that in 2005, the Phillips neighborhood was split up into Ventura Village, Phillips West, Easy Phillips, and Midtown Phillips (see neighborhood profile). The 2000 population is taken from Wikipedia:
Neighborhoods
- Definitive list of Minneapolis Neighborhoods last updated 2006-01-01. A scraper of this data has been made. Downloaded locally (
data/neighborhoods/minneapolis/minneapolis-neighborhoods-2012.json
). These contain keys that should be used throughout the application.- Download JSON with this command, though this data should not change anytime soon:
wget -O data/neighborhoods/minneapolis/minneapolis-neighborhoods-2012.json "https://api.scraperwiki.com/api/1.0/datastore/sqlite?format=json&name=minneapolis_neighborhoods&query=select%20*%20from%20%60swdata%60"
- Download CSV:
wget -O data/neighborhoods/minneapolis/minneapolis-neighborhoods-2012.csv "https://api.scraperwiki.com/api/1.0/datastore/sqlite?format=csv&name=minneapolis_neighborhoods&query=select%20*%20from%20%60swdata%60"
- Download JSON with this command, though this data should not change anytime soon:
- Downloaded shapefile of the neighborhoods was provided by the City of Minneapolis:
wget -O data/neighborhoods/minneapolis/minneapolis-neighborhoods.shp.zip "http://www.minneapolismn.gov/www/groups/public/@bis/documents/webcontent/wcms1p-106980.zip"
. This was extracted with:cd data/neighborhoods/minneapolis/ && unzip minneapolis-neighborhoods.shpfile.zip -d minneapolis-neighborhoods.shpfile; cd -;
- This has been converted to a GeojSON file with:
ogr2ogr -f "GeoJSON" data/neighborhoods/minneapolis/minneapolis-neighborhoods.geo.json data/neighborhoods/minneapolis/minneapolis-neighborhoods.shpfile/NEIGHBORHOODS.shp -t_srs "EPSG:4326"
- This has been converted to a GeojSON file with:
Hacks
- Currently using custom version of Backbone.stickit, see pull request.