Exploration of the new Green Line
You can see this project in action at Who lives on the Green Line.
Unless otherwise noted, MinnPost projects on Github are story-driven and meant for transparency sake and not focused on re-use. For a list of our more reusable projects, go to code.minnpost.com.
- Green Line data from MetroTransit.
- Green line is route 902 (temporarily) and will be replacing route 50.
- MetroTransit route data via DataFinder
- Stop data from the Planned Transitway Stations dataset on DataFinder
- Census data by tract from CensusReporter.
- Ian Dees was very kind to query the Census Reporter database to figure out which Census Tracts were next to or very close to the Green Line route. Posted here.
- This was also augmented by Jane Tigan to include a couple tracks that are included in the Funders Collaborative Tracker.
- Manually stored in
data/census-tracts-ids.json. - http://api.censusreporter.org/1.0/data/show/latest?table_ids=B01001&geo_ids=14000US27053003800
- Landmark data traced from GeoJSON.io.
Get data sources:
mkdir -p data && cd data && wget ftp://gisftp.metc.state.mn.us/TransitRoutes.zip && unzip TransitRoutes.zip -d metrotransit-routes-shps && wget ftp://gisftp.metc.state.mn.us/PlannedTransitwayStations.zip && unzip PlannedTransitwayStations.zip -d metrotransit-planned-stations-shps && wget https://gist.githubusercontent.com/zzolo/9e60510cae6db58eabd7/raw/map.geojson -O landmarks.geo.json; cd -;`
- Use GDAL to convert routes and stops to GeoJSON for easier processing:
ogr2ogr -f "GeoJSON" data/metrotransit-routes.geo.json data/metrotransit-routes-shps/TransitRoutes.shp -t_srs EPSG:4326 && ogr2ogr -f "GeoJSON" data/metrotransit-planned-stops.geo.json data/metrotransit-planned-stations-shps/PlannedTransitwayStations.shp -t_srs EPSG:4326; - Get green line data:
node data-processing/get-green-line.js - Get census data:
node data-processing/get-census-tracts.js - Convert to TopoJSON for network performance and to fix some polygon issues.
topojson data/landmarks.geo.json -p > data/landmarks.topo.jsontopojson data/census-tracts.geo.json -p > data/census-tracts.topo.json
All commands are assumed to be on the command line, often called the Terminal, unless otherwise noted. The following will install technologies needed for the other steps and will only needed to be run once on your computer so there is a good chance you already have these technologies on your computer.
-
Install Git.
- On a Mac, install Homebrew, then do:
brew install git
- On a Mac, install Homebrew, then do:
-
Install NodeJS.
- On a Mac, do:
brew install node
- On a Mac, do:
-
Optionally, for development, install Grunt:
npm install -g grunt-cli -
Install Bower:
npm install -g bower -
Install Sass:
gem install sass- On a Mac do:
sudo gem install sass
- Install Compass:
gem install compass
- On a Mac do:
sudo gem install compass
- On a Mac do:
Get the code for this project and install the necessary dependency libraries and packages.
- Check out this code with Git:
git clone https://github.com/MinnPost/minnpost-green-line-demographics.git - Go into the template directory:
cd minnpost-green-line-demographics - Install NodeJS packages:
npm install - Install Bower components:
bower install
- Run:
grunt server- This will run a local webserver for development and you can view the application in your web browser at http://localhost:8808.
- By default, running a local server will show you the local development version. But there are other builds that you can view by changing the query parameters. Do note that you may have to run the build and deploy things for things to work normally.
- Local build: http://localhost:8808/?mpDeployment=build
- Build deployed on S3: http://localhost:8808/?mpDeployment=deploy
- Embedded version with local build: http://localhost:8808/?mpDeployment=build&mpEmbed=true
- Embedded version with S3 build: http://localhost:8808/?mpDeployment=deploy&mpEmbed=true
Development will depend on what libraries are used. But here are a few common parts.
js/app.jsis the main application and will contain the top logic.
Adding libraries is not difficult, but there are a few steps.
- User bower to install the appropriate library:
bower install library --save - Add the appropriate reference in
js/config.jsso that RequireJS knows about it. - Add an entry in the
dependencyMapobject inbower.json. This is used to automatically collect resources in the build process. It is possible, like withminnpost-stylesthat multiple entries will need to be made, one ber.jsfile. Here is an example:
// Should be bower identifier. Order matters for build, meaning that any dependencies should come first.
"library": {
// Name used for reference in RequireJS (some modules expect dependencies with specific case, otherwise its arbitrary and you can just use the library name from above).
// If this is not a JS library, do not include.
"rname": "library",
// (optional) Path to un-minified JS files within bower_components excluding .js suffix.
"js": ["library/dist/library"],
// (optional) Path to un-minified CSS files within bower_components excluding .css suffix.
"css": ["library/dist/css/library"],
// (optional) Path to un-minified IE-specific CSS files within bower_components excluding .css suffix.
"ie": ["library/dist/css/library.ie"],
// What is expected to be returned when using as a RequireJS dependency. Some specific libraries, like jQuery use $, or backbone returns the Backbone class.
// If this is not a JS library, do not include.
"returns": "Library"
}
Unfortunately there are no tests at the moment.
To build or compile all the assets together for easy and efficient deployment, do the following. It will create all the files in the dist/ folder.
- Run:
grunt
Deploying will push the relevant files up to Amazon's AWS S3 so that they can be easily referenced on the MinnPost site. This is specific to MinnPost, and your deployment might be different.
- Run:
grunt deploy- This will output a bit of HTML to if you want to use the project as an embed.
There are to main ways to include the necessary HTML in a page in order to run the project.
- Copy the relevant parts from
index.html.- This has the benefit of showing messages to users that have older browsers or have Javascript turned off. This also uses the build that separates out the third-party libraries that are used and are less likely to change; this gains a bit of performance for users.
- Copy the embed output from
grunt deploy.
List any hacks used in this project, such as forked repos. Link to pull request or repo and issue.
MinnData, the MinnPost data team, is Alan, Tom, and Kaeti and all the awesome contributors to open source projects we utilize. See our work at minnpost.com/data.
.--.
`. \
\ \
. \
: .
| .
| :
| |
..._ ___ | |
`."".`''''""--..___ | |
,-\ \ ""-...__ _____________/ |
/ ` " ' `"""""""" .
\ L
(> \
/ \
\_ ___..---. L
`--' '. \
. \_
_/`. `.._
.' -. `.
/ __.-Y /''''''-...___,...--------.._ |
/ _." | / ' . \ '---..._ |
/ / / / _,. ' ,/ | |
\_,' _.' / /'' _,-' _| |
' / `-----'' / |
`...-' `...-'