4
$\begingroup$

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.

$\endgroup$
  • 2
    $\begingroup$ 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) $\endgroup$ – Mr.Wizard Aug 19 '14 at 20:33
  • $\begingroup$ 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). $\endgroup$ – astrak Aug 20 '14 at 5:09
7
$\begingroup$

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

|improve this answer|||||
$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – astrak Aug 20 '14 at 5:05
1
$\begingroup$

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

|improve this answer|||||
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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