Figuring out the best place to live in Helsinki
wanhala.net
wanhala.net
In this case I simply took a large number of addresses, ran them through the API for public transit for a random fixed workday (A tuesday morning 8 am commute) to a fixed central address. Then I plotted the times in a heatmap in the format Google maps uses and made a map overlay with the heat map.
It makes a nice spiral galaxy like map where the commuter train stations make little islands of short commute time far away from the city.
http://commutemap.azurewebsites.net/
(Static pic if you don't want to zoom in it and eat my free azure bandwidth... http://prnt.sc/e57bsc). Thinking about it now the dang thing ended up being completely static so it should be possible to just host for free somewhere (github?) rather than cloud. Uses my msdn "testing" sub now...
Outcome: bought place in the orange/red area and started working from home instead :)
Limitations: 1) target address is fixed, new target (e.g. new job location) needs a whole new map. But central stockholm is pretty small and walkable so this works pretty well if your office is central. 2) Interpolation between known points/addresses uses no kind of path finding. It assumes you can walk e.g. 200m in a straight line from an address to the closest bus stop. That might not be what you want to do if it e.g. means crossing water...
Thanks
The most important bit is the public transit API: it allows returning travel times between addresses or geographic coordinates. For stockholm there is the trafiklab api which is excellent, and free. https://www.trafiklab.se/api/
A naive implementation would just generate the map by taking each map pixel, figuring out the lat/lon on the map, and calling the transit API to get the color of the pixel. That however will be painfully slow (a year?) since the API will throttle/limit the number of calls.
So a better approach is to sample some subset of points and interpolate. Most of the larger city area is not populated so a lot of time would be wasted trying to query transport times from places in water or forrests. The best solution I could come up with was to use a list of addresses, because those say where people live. So I needed a list of addresses either with lat/lon coordinates, or a service that could give me lat/lon from the addresses (Such as openstreetmap). I found a real estate api at Booli that provided a large number of addresses including lat/lon. Perfect. I just made a simple script to dump a large list of many thousand addresses to a little db I had.
So I loop all the addresses in my address list, using a timer to throttle the transit API calls to the allowed rate. The results (coordinate, transit time) I insert into a QuadTree for perf - a list would work just as well but finding the nearest point later would be slow as hell.
After that is done, I generate map tiles. For each pixel of each tile I get the lat/lon, and then do a lookup in the QuadTree for the closest known point within some max_walking_distance (I chose 2km) for which I know public transit (Taking the shortest travel time if there are several). This can now run completely offline so will complete generating maps for all the zoom levels in not many minutes (I chose zoom levels 5..14 which covers the use case nicely).
The app itself is then just a static html with some google maps api calls to serve the overlay map from the static tile images.
Note the demo moved: https://andersforsgren.github.io/commutemap/
Disclaimer: Like written above I created it so I am obviously the founder
If somebody adds a page that does not work they can simply click on the (!) and inform us, we add then support asap.
Your commute depends on your job, where the price depends on safety, size, shops in the area, noise pollution, air pollution, parc proximity etc...
Connection is one factor but you can't just say "it's expensive, therefore faster to go to work"
Nitpick: Rainbow (jet) color maps can be confusing. Better to use a perceptually uniform one such as viridis, see e.g. https://bids.github.io/colormap/
[0] https://jiffyclub.github.io/palettable/cubehelix/
[1] http://www.ifweassume.com/2013/05/cubehelix-or-how-i-learned...
Perhaps it could be improved if the algorithm took an input of common routes and times, then tried to find an optimal location for these routes. This way the algorithm could be scaled as needed and provide a more realistic scenario. Is this something you considered?
So I did my own analysis: I calculated the travel time from every address to every other address in Helsinki around 7:30-8:00am (about 30 billion searches total!). Then I calculated the (weighted) average travel time to anywhere in the city, using amount of jobs in the target area as weight.
That would seemingly bias towards centrally-located addresses (travel time & number of jobs), and his heat maps seem to show this. I believe you could pretty easily duplicate what he's doing with a few dozen randomly sampled routes. Or is there more to it?
Just might spice it up if you partition the bucket of all routes into spaces defined by your lifestyle too. It would be interesting to see what the best address in Helsinki is for hipsters. Or families. Or athletes. Or business people...
This is so cool because anyone who has moved has faced this problem.
Don't get me wrong. I found the map highly interesting but maybe in determining best places to live it's a bit of a stretch. There might more value here for businesses that aim to be easily reachable.
It's not easy to optimize the travelling salesman problem, but if you're happy to brute force it using 30B searches it's incredibly straightforward.
Disregarding changes in travel time due to the different time of say, we know that A -> Origin + Origin -> B is an upper bound on A -> B so the solution is still good even if it's not quite optimal.
Have you seen http://mak.hsl.fi/? It's kind of that, though you do have to specify the starting/end point.
How long did it all take?
As a consultant you surely don't travel to every part of the city as frequently, and maybe the expensive neighbourhoods are rightfully expensive because that is the place where those who hire consultants live.
Nonetheless a really cool visualisation/idea!
the end result is nice though.