TransWikia.com

A function of a list of, say, 100 cities, and we want the FURTHEST point in the Continental US

Mathematica Asked on December 11, 2020

I haven’t given up on this problem but not being fluent in the Mathematica Wolfram Language, mainly because I don’t know the commands.
Tia

2 Answers

Assuming the answer to my comment is yes, here is one way to do it

polygonUS = Entity["Country", "UnitedStates"]["Polygon"];
borderPoints = polygonUS[[1, 1, 1]] // Map[GeoPosition];

furthestFrom[city_, borderPoints_] := 
  AssociationThread[borderPoints -> Normal@GeoDistance[borderPoints, city]] //
  ReverseSort // Take[#, 1] &

london = Entity["City", {"London", "GreaterLondon", "UnitedKingdom"}];
furthest = furthestFrom[london,borderPoints]
<|GeoPosition[{32.5343, -117.124}] -> Quantity[5504.35, "Miles"]|>
furthestPosition = First@Keys@furthest;
furthestCities = GeoNearest["City", furthestPosition, 2]
{Entity["City", {"ImperialBeach", "California", "UnitedStates"}], 
 Entity["City", {"SanDiego", "California", "UnitedStates"}]}
GeoGraphics[{Red, GeoPath[{city, furthestPosition}, "Geodesic"]}, 
 GeoRange -> {{10, 70}, {-120, 10}}]

enter image description here

Answered by Rohit Namjoshi on December 11, 2020

I continued to fiddle around and came up with this, San Francisco is just an example. In this case, it looks like Mahchester, NH is the furthest to San Francisco.

cityCenter = Interpreter["City"]["San Francisco"]
cities = CityData[{Large, "United States"}];
table1 = Table[{cities[[k]], 
    QuantityMagnitude[TravelDistance[cities[[k]], cityCenter]]}, {k, 
    Length[cities]}];
First[Sort[table1, #1[[2]] >=  #2[[2]] &]]

Answered by Veritas Lux on December 11, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP