Message Boards Message Boards

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

Do All Roads Lead to Rome? The Answer is Surprisingly Beautiful by Gabrielle Bruney, is an interesting post that was recently published in theCreatorsproject blog. It shows the results of Moovel Lab's team (Benedikt Groß, Raphael Reimman and Philipp Schmitt), that visually proof the old saying that “all roads lead to Rome”. But Do All Roads Lead to Rome? The answer using the Wolfram Language and its newly built-in TravelDirections is surprisingly beautiful:

Roads to Rome

roadsToRome=ParallelMap[TravelDirections[{Entity["City",#],Entity["City", List["Rome", "Lazio", "Italy"]]},"TravelPath"]&,Flatten[CountryData["Europe","LargestCities"][[All,2]],1]];
EdgeForm[White],Polygon[EntityClass["Country", "Europe"]],
EdgeForm[],Polygon[EntityClass["Country", "Europe"]],Red,Opacity[.1],roads},GeoBackground->GeoStyling[LightBlue],GeoProjection->"Mercator",GeoRange->{{34.63,65.27},{-24.53,40.222}},ImageSize->1000];

Notice that I mapped over 30,000 large cities across Europe and the resulting GeoPath from each to Italy’s capital.

To generalize this to the whole World, just bear in mind that there are 10 cities called Rome in the US alone:


{ Entity["City",List["Rome","Lazio","Italy"]], Entity["City",List["Rome","Georgia","UnitedStates"]], Entity["City",List["Rome","NewYork","UnitedStates"]], Entity["City",List["Rome","Wisconsin","UnitedStates"]], Entity["City",List["Rome","Illinois","UnitedStates"]], Entity["City",List["Rome","Maine","UnitedStates"]], Entity["City",List["RomeJefferson","Wisconsin","UnitedStates"]], Entity["City",List["Rome","Pennsylvania","UnitedStates"]], Entity["City",List["Rome","Iowa","UnitedStates"]], Entity["City",List["Rome","Ohio","UnitedStates"]] }

GeoGraphics[{Red, PointSize[Large], Point[Drop[CityData["Rome"], 1]]}, GeoProjection -> "Mercator"]



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: Moderation Team

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["" <> 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"]*)



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,


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

Dear Sander,

yes, it is sort of a Voronoi Diagram. One of the problems is that the metric is not symmetric. It has been mentioned that the distance from A to B is not necessarily the same as the one from B to A, because of e.g. one way streets; this might however not be a problem in this particular case of inter-city movements.

Also, the distances lead to interesting effects on the edges between "Voronoi cells".

I think that I would just overlay a standard (Euclidean) Voronoi diagram and see what happens; it should be quite close to the catchment areas. I also think that the sea areas are not such a big problem. I guess one would use the entire square region for the analysis and then just use a mask to black out the sea.

Great work!


PS: Even larger computers I have keep crashing on Bernat's program. So I have not got any good data to work with yet.

POSTED BY: Marco Thiel

You might have to use a fast equivalent of GeoDistance, as the earth is curved rather than flat: Norm[{lat1,lon1}-{lat2,lon2}] probably won't give nice results. I'm not sure how to do Voronoi tesselations (quickly) with different norms (Manhattan norm for example).

POSTED BY: Sander Huisman

Hi Marco, I'm really sorry to hear that. I should have warn you about the difficulty of rendering 3.96GB of travel directions data in a single GeoGraphics. My suggestion is to decrease the resolution of the GeoPaths. Here is a simple example that tries to find all the travel directions to Rome from all the other capitals of the World. 131 out of 239 capital cities can be reached by car from Rome, being Singapore the capital that takes the longest to reach ( 671220 seconds, almost 8 days driving straight ).

directions = DeleteCases[directions, _Symbol];
(* Merge the GeoPaths, decrease the resolution by taking a point every 500 points, and color the paths with VertexColors normalized according to the longest travel time: 671220 seconds *)
(* Render the colored geopaths in GeoGraphics *)

All capitals to Rome

Attached is the notebook with the colored paths exported as an m file.

POSTED BY: Bernat Espigulé

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


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:


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
or Discard

Group Abstract Group Abstract