Group Abstract Group Abstract

Message Boards Message Boards

Do All Roads Lead to Rome? The Answer is Surprisingly Beautiful

POSTED BY: Bernat Espigulé
13 Replies

enter image description here - another post of yours has been selected for the Staff Picks group, congratulations !

We are happy to see you at the top of the "Featured Contributor" board. Thank you for your wonderful contributions, and please keep them coming!

POSTED BY: EDITORIAL BOARD

Hi again,

one of the little problems when you want to do these travel directions within cities is that the documentation only shows how to calculate TravelDirections between cities and/or landmark buildings.museums etc. For house to house (or street to street) directions you need the exact geolocations of the start and endpoint.

This little function might come in handy:

location[str_String] :=
GeoPosition@(ToExpression[{StringSplit[#, {"<lat>", "</lat>"}][[2]], StringSplit[#, {"<lng>", "</lng>"}][[2]]}] & @
    StringJoin@Flatten@Import["https://maps.googleapis.com/maps/api/geocode/xml?address=" <> StringReplace[str, " " -> "+"]]) 

With it you can enter two addresses as strings like so:

loc1 = location["21 Union Street Aberdeen UK"]; 
loc2 = location["University of Aberdeen UK"];

Then you can -as always- use:

TravelDirections[{loc1, loc2}]["Dataset"]

to get:

enter image description here

Or else:

TravelDirections[{loc1, loc2}]["TravelDistance"]
(*Quantity[1.98282, "Miles"]*)

Cheers,

Marco

POSTED BY: Marco Thiel

That's very handy indeed. Marco, thanks for sharing it!

POSTED BY: Bernat Espigulé

Hi Bernat and Sander,

very nice posts (this one and Sander's). I wonder whether this could be adapted to model pursuit and evasion patterns. Suppose we have a bank robbery in a given bank in a city. And suppose we know how much time the robbers had to escape; we should then be able to calculate how far they have gotten - indeed travel time would be important here. Also, we could read your maps the other way around: we don't end up at Rome, but escape from Rome. Of course, for a bank robbery one would consider roads within a city, similar to Bernat's beautiful Runkeeper blog post. The "stronger" the colour the more likely the robbers used that road for their escape. This assumes, of course, that any of the other cities/points would be an equally likely endpoint. It should be easy of course to attach different weights to the individual endpoints. This could be interesting to predict potential escape routes for terrorists.

So, we would sort of consider this to be a graph with the special form of a rooted tree, I suppose. At that point we could use all sorts of graph theoretical approaches. This could actually be interesting in relation to @Vitaliy Kaurov 's question regarding graph complexity.

Another idea would be to use either the multiple "Romes" in the US or do something like what they do in the original post with the capitals of Europe and then overlay a Voronoi tessellation to the image. If you look at it, the "basins of attraction" are nearly defined by Voronoi tiles.

It might be interesting to calculate some fractal dimension of that network...

Another related question might be the optimisation of transport network. My favourite example is the Japanese railroad network as modelled by slime molds.

I would have tried some of that myself, but I only have limited CPU power right now, and the little I have left is still running Bernat's code...

Very nice posts indeed,

Marco

POSTED BY: Marco Thiel

Hi Marco,

Thanks for the reply; In fact it IS a Voronoi diagram! The measure is just not the usual Euclidean norm, but the a custom norm (TravelDistance)! Given the great profusion of roads throughout Europe, I think the 'normal' Voronoi (using GeoDistance) and custom Voronoi (Using TravelDistance) will be quite the same in those places that are not bordered by masses of water. There is not a lot of CPU necessary right? Memory and internet connection is more crucial I think...

A more general question about TravelDirections: Does it use shortest distance, fastest time, most economic, a mix?

POSTED BY: Sander Huisman
POSTED BY: Marco Thiel
POSTED BY: Sander Huisman
Attachments:
POSTED BY: Bernat Espigulé

Very nice! To speed up the visualisation you can use the travelpath option:

pts=CirclePoints[{45.0,5.0},3,10000];
AbsoluteTiming[GeoGraphics[GeoPath[pts,"TravelPath"]]]
AbsoluteTiming[GeoGraphics[GeoPath[pts]]]

roughly 90x faster!

POSTED BY: Sander Huisman

Great tip, thanks!

POSTED BY: Bernat Espigulé

I'm not sure what the difference is, but I think it just draws straight lines rather then curves (Geodesic). So you can just as well use:

GeoPath[pts,"TravelPath"]
Line[Reverse/@pts]

look the same to me...

POSTED BY: Sander Huisman

Wow! Nicely done using Opacity!! I just made a very similar post here! I was curious about the roads to the city I live in. I really wanted to change the thickness, so it took some more lines of code...

POSTED BY: Sander Huisman

Sander, that's really well-executed! Benoit Mandelbrot would be happy to see that not only nature but human-made roads can generate beautiful fractals.

POSTED BY: Bernat Espigulé
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard