0
$\begingroup$

How can I plot various points on a world map and compare distances? For example, the distance between Jerusalem and Westford, MA compared to the distance between Westford, MA and Recife, Brasil? Then for a triangulation of the three points and measure the difference of distance between the three points?

$\endgroup$

1 Answer 1

3
$\begingroup$

Entering Cities as Entities

For the cities, the following can be used

wes = Entity["City", {"Westford", "Massachusetts", "UnitedStates"}]
jer = Entity["City", {"Jerusalem", "Jerusalem", "Israel"}]
rec = Entity["City", {"Recife", "Pernambuco", "Brazil"}]

These input forms can be discovered by evaluating, for example, InputForm @ Ctrl= Recife, where Ctrl= means the control key + equal sign.

Plotting with GeoMarkers

Use GeoMarkers for plotting the city locations. Use GeoPath for the paths. See the documentation for the various path options.

GeoGraphics[{GeoMarker /@ {wes, jer, rec},
  GeoPath /@ Subsets[{rec, jer, wes}, 2]}]

enter image description here

Check the documentation on GeoGraphics and GeoRange for how to zoom out.

Distance

Use GeoDistance for the distance between the cities.

GeoDistance[wes, jer]   (*  Quantity[5526.35, "Miles"]  *)
$\endgroup$
2
  • 1
    $\begingroup$ +1 To include tooltips: GeoGraphics[{Tooltip[GeoMarker[#], #] & /@ {wes, jer, rec}, Tooltip[GeoPath@#, GeoDistance @@ #] & /@ Subsets[{rec, jer, wes}, 2]}] // Quiet $\endgroup$
    – Bob Hanlon
    Dec 9, 2020 at 14:31
  • $\begingroup$ Thanks for the responses, LouisB and Bob Hanlon. $\endgroup$
    – DeathPunch
    Dec 10, 2020 at 23:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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