Message Boards Message Boards

Trying to find visit all the city parks in Great Falls, Montana

Posted 10 years ago

I'm trying to visit all the city parks in Great Falls, Montana in a single day, and I cannot figure a way to get Wolfram Alpha to calculate the shortest distance needed to visit all of them. Can anyone help me out with the code?

POSTED BY: Patrick Wolf
7 Replies

Curiously enough I have just seen this recent article published - also about Montana, Mathematica and the shortest path:

All 56: Solving Montana's 'traveling salesman' problem

POSTED BY: Vitaliy Kaurov
Posted 10 years ago

Thank you!

One final question: for the parks on the outskirts of town should I just follow the roads? Swimming across the longest river in North America and running across an airport are not very practical. However, we will be on foot so some of the parks in town might be able to get to by cutting across some blocks/empty lots.

Thanks again for all the help.

Patrick

POSTED BY: Patrick Wolf

Hi again,

borrowing the main idea from Vitaliy's far superior representation, the city park tour would look like this:

ImageMultiply[
  GeoListPlot[Drop[parkpos, {6}], GeoZoomLevel -> 13, 
   GeoBackground -> "StreetMap", ImageSize -> 1500], 
  GeoListPlot[Drop[parkpos, {6}][[order2]], 
   GeoBackground -> GeoStyling["ContourMap", Contours -> 15], 
   PlotMarkers -> GeoMarker, Joined -> True, 
   ImageSize -> 1500]] // Sharpen

enter image description here

Cheers,

Marco

POSTED BY: Marco Thiel
POSTED BY: Marco Thiel
POSTED BY: Marco Thiel

Using Marco's approach in a bit different way:

montParks = GeoEntities[Entity["AdministrativeDivision", {"Montana", "UnitedStates"}], "Park"]

enter image description here

order = Last[FindShortestTour[GeoPosition /@ montParks]]
Out[] = {1, 4, 5, 6, 3, 2, 1}

ImageMultiply[

  GeoListPlot[montParks, GeoZoomLevel -> 7, 
   GeoBackground -> "StreetMap", ImageSize -> 900],

  GeoListPlot[montParks[[order]], PlotMarkers -> GeoMarker, 
   GeoBackground -> "ContourMap", Joined -> True, ImageSize -> 900]

  ] // Sharpen

enter image description here

POSTED BY: Vitaliy Kaurov

Dear Vitaliy,

I wonder whether it would be nice to use Tooltip to add photos of the markers that show the parks. I thought that one might use something like:

url = Import["http://www.greatfallsmt.net/recreation/city-parks", 
   "Data"];
parks = url[[1, 2, 1, 1, 2]][[All, 1]];
images = {}; For[i = 1, i <= Length[parks], i++, 
 result = Import[
   StringJoin[
    "https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=",
    StringReplace[parks[[i]], " " -> "+"], 
    "+Montana+Great+Falls+Park+City"], "JSON"]; 
 AppendTo[images, 
  Import["url" /. ("results" /. ("responseData" /. result))[[1]]]]]

to get the photos from google. This does not work quite yet, but one could download more than one image per search and then choose the best one.

Best wishes from Aberdeen,

Marco

POSTED BY: Marco Thiel
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract