# Density plot of city data

I try to solve a bit tricky problem. I want define line (or vector) between some geographical points with weights (for example how many transactions has been done between these cities).

I tried this way:

c1 = CityData["Paris", "Coordinates"] ;
c2 = CityData["London", "Coordinates"];
c3 = CityData["Hong Kong", "Coordinates"];

ListDensityPlot[{{c1, c2, 5}, {c2, c3, 1}}]


Where 5 and 1 in ListDensityPlot are weights.

When I evaluate this code I always get error message. Is it possible to make this simalution?

Thank you very much.

• Is ListDensityPlot really what you mean to use? It sounds nothing like the description "I want define line (or vector) between some geographical points with weights." Have you looked at Graph? Is this something like what you want?: (6440) – Mr.Wizard Aug 19 '14 at 20:33
• Yes, you are right. Your link looks like what I need. But when we use GeoGraphics it would be also possible to use density, isn't it? Check my comment bellow (we have x as well as y coordinates and z is density). – astrak Aug 20 '14 at 5:09

loc1 = "Paris";
loc2 = "London";
loc3 = "Hong Kong";

{c1, c2, c3} = CityData[#, "Coordinates"] & /@
{loc1, loc2, loc3};

GeoGraphics[{
Red, AbsoluteThickness,
Tooltip[GeoPath[{c1, c2}],
loc1 <> " - " <> loc2 <> ": " <> ToString[GeoDistance[c1, c2]]],
Blue, AbsoluteThickness,
Tooltip[GeoPath[{c2, c3}],
loc2 <> " - " <> loc3 <> ": " <> ToString[GeoDistance[c2, c3]]]},
GeoRange -> {{20, 60}, {-10, 120}},
Frame -> True] • It looks great. But is it possible to add there also density or something like 3D graph? It is maybe stupid but I think we have x as well as y coordinates and z is density. In this case it doesn't matter but when we have many lines it would be more interesting. – astrak Aug 20 '14 at 5:05

some ideas using TreePlot

TreePlot[{{1 -> 2, 50}, {3 -> 1, 70}, {2 -> 3, 100}} /. {1 -> "Paris",
2 -> "London", 3 -> "Hong Kong"}, VertexLabeling -> True]

(* sophisticated version *)
vertexLabel[city_] :=
city <> "\n" <> ToString@CityData[city, "Coordinates"]
TreePlot[{{1 -> 2, 50}, {3 -> 1, 70}, {2 -> 3, 100}} /. {1 ->
vertexLabel@"Paris", 2 -> vertexLabel@"London",
3 -> vertexLabel@"Hong Kong"}, VertexLabeling -> True] 