Seattle Car2Go Visualization with D3
If you want to see an awesome map, click on this!
In the past year there have been a number of inspiring geo visualizations that make d3.js a natural choice for web mapping projects. You can see a really good set of examples here.
Car2Go in the Northwest
One recent map visualization that got our attention was Matt Sack’s awesome timeslider of car2go movement in Portland. This visualization shows the car share activity over a three-day period. For those that don't know, car2go is a car share program with some perks that play off drivers' natural animosity to city driving. Basically you can leave the car almost anywhere after a one-way trip and avoid getting tickets.
The number of car2go users seems to have exploded in Portland and Seattle and we're not the only people asking the very basic questions -- who is using these cars and where are they going?
Matt Sacks visualization begins to answer these questions while also leaving room for more improvement. Excited by the possibilities we decided to port his Portland visualization over for the Seattle area.
Here's what we learned
In this project node can be used to serve the static files and run cron jobs. We only use it here as an environment to run bash-like worker scripts that will suck down the JSON from car2go's REST api and write it to a file. There's an upload.js script that will dump the output JSON cars file into an Amazon S3 bucket using the aws-sdk for node.
Written by Matt Sacks, this small library is a mapreduce framework.
MapBox.js is a mapping framework that wraps Leaflet and interacts with MapBox hosting. It would usually provide the standard mapping tools for panning, zooming and requesting more tiles on user interaction. You'll quickly notice that this type of interactivity is not available in the app. In this project, mapbox.js is really only used in a couple ways
- Matt Sacks seems to have used TileMill to create a custom tileset as a backdrop to his Portland map. He then hosts those tiles on MapBoox hosting. So it's used here to request those tiles as a layer to give us geographic context
- Once we get the lat/long points of the cars we need to find where these points are on the map ( it's in a different projection ). We use mapbox.js to get this pixel location so d3.js can properly draw it.
The meat of the visualization is in d3.js. It is responsible for rendering the points and the timeslider. It is also creates the eventful interface between these components so we get an animation.
Ways To Improve
We thought of many interesting ways to alter this app. Maybe in future posts we will try them out. But for now you will have to enjoy our start of a brainstorming session.
- Create an interface between the mapping framework events ( pan, zoom, select point ) and d3.js animation. This will make the map more interactive so users can get a better sense of what's going on in certain areas. Most users will want to click on a point and see some kind of information
- Select cars and time-slide them individually
- Track individual cars. Strangely this is more possible than you might imagine since we realize that the ID’s associated with the cars actually matches the license plates. This is also a security flaw in car2go's API since they discourage people from tracking individual cars