3 ms·
I did a similar one for Stockholm but for the greater metro area rather than on street level, for the commute time into the city (When I was looking for a place
by alkonaut 10y ago
I did a similar one for Stockholm but for the greater metro area rather than on street level, for the commute time into the city (When I was looking for a place to live outside). I
What I really wanted to do was find "underpriced areas" where commutes are faster than house prices indicate.
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/ 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 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...
- muninn_ 10y agoThat's cool. Could I bother you for more information on how to do this? I'd like to try that for where I live. Thanks
- alkonaut 10y agoI'll dig through the source tomorrow. Check back.
- alkonaut 10y agoOK: I found the old source and I'll try to outline it (trust me it's a bit one-off since it's not usued in the production so it's easier to explain in english). 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/ 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/ https://andersforsgren.github.io/commutemap/
- dmd 10y agoError 403 - This web app is stopped.
- alkonaut 10y agoThanks for the heads up - will try to find a new home. It's on my "not for production" azure sub in which they apparently kill any app with a suspicious amount of traffic.
- alkonaut 10y agoNew url (moved off Azure as the quota was reached) https://andersforsgren.github.io/commutemap/ https://andersforsgren.github.io/commutemap/
- blackbagboys 10y agoFor those interested, there is a website that does this for a number of cities, mostly clustered in the US & Europe: http://www.mapnificent.net/ http://www.mapnificent.net/
- alkonaut 10y agoCool, their logo even looks like my map. Nice to see they didn't have Stockholm, I hate it when I make something only to discover theres a nicer one out there already...
- mgv11 10y agoThat is a great link! We are just starting to look for a new place outside the city and that will come in very handy.