Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question
2  
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 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 at 5:09

2 Answers 2

EDITED to add Tooltips

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

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

GeoGraphics[{
  Red, AbsoluteThickness[5],
  Tooltip[GeoPath[{c1, c2}],
   loc1 <> " - " <> loc2 <> ": " <> ToString[GeoDistance[c1, c2]]],
  Blue, AbsoluteThickness[1],
  Tooltip[GeoPath[{c2, c3}],
   loc2 <> " - " <> loc3 <> ": " <> ToString[GeoDistance[c2, c3]]]},
 GeoRange -> {{20, 60}, {-10, 120}},
 Frame -> True]

enter image description here

share|improve this answer
    
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 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]

cityDataPlot

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.