1

I have hitherto found a solution to this problem.

Designate a city in the continental USA as cityCenter.

Make a table with all large cities in the USA. I could also just try for large cities.

Of those cities in the list, the list includes data from the continental USA.

Use a module to list all cities which match the following criteria; distance between cityCenter and that city is at most a fixed radius. If the distance is less than a fixed real number, add to final list.

Example: From San Francisco, some cities as far as Sacramento appear but not for Florida.

Any insights would be appreciated.

Sjoerd Smit
  • 23,370
  • 46
  • 75
Veritas Lux
  • 465
  • 2
  • 8

2 Answers2

6

This sort of thing is really easy to do in Mathematica:

allCities = CountryData["UnitedStates", "LargestCities"];
cityCenter = Entity["City", {"SanFrancisco", "California", "UnitedStates"}];
Select[allCities, GeoDistance[#, cityCenter] < Quantity[500, "Kilometers"] &]

{San Jose, San Francisco, Fresno, Sacramento, Oakland, Bakersfield, Stockton, Reno, Fremont}

The first time you run this, it might take some time while it downloads all required data.

To input a city into a notebook, press Ctrl+= to bring up a free-form input field. You can type the name of the city in there and Mathematica will try to find the city you meant. That's how I produced Entity["City", {"SanFrancisco", "California", "UnitedStates"}] in this example.

Sjoerd Smit
  • 23,370
  • 46
  • 75
  • This is using GeoDistance and I'm looking for TravelDistance. Does that matter? – Veritas Lux Aug 15 '20 at 17:20
  • Thank you. Some terms like allCitiesGeoGraphics don't seem to have definitions. – Veritas Lux Aug 15 '20 at 23:01
  • @VeritasLux Yes, you can use TravelDistance as well. You just need to use TravelDistance[{#, cityCenter}] instead of GeoDistance[#, cityCenter] (note the curly brackets). It will also be a lot slower than GeoDistance. – Sjoerd Smit Aug 16 '20 at 19:17
3

Using allCities and cityCenter from Sjoerd's answer, we can also use GeoWithinQ and GeoDisk as follows:

geodisk = GeoDisk[cityCenter, Quantity[500, "Kilometers"]];

selected = Select[GeoWithinQ[geodisk]] @ allCities

enter image description here

GeoGraphics[{geodisk, Red, Point@ GeoPosition @ selected, 
  PointSize[Large], Blue, Point @ GeoPosition @ cityCenter}]

enter image description here

See also this closely related Q/A: Using Geo commands, how do I get a list of cities that all meet the following criteria

kglr
  • 394,356
  • 18
  • 477
  • 896