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?
1 Answer
$\begingroup$
$\endgroup$
2
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]}]
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"] *)
-
1$\begingroup$ +1 To include tooltips:
GeoGraphics[{Tooltip[GeoMarker[#], #] & /@ {wes, jer, rec}, Tooltip[GeoPath@#, GeoDistance @@ #] & /@ Subsets[{rec, jer, wes}, 2]}] // Quiet
$\endgroup$ Dec 9, 2020 at 14:31 -
$\begingroup$ Thanks for the responses, LouisB and Bob Hanlon. $\endgroup$ Dec 10, 2020 at 23:23