Skip to content

Instantly share code, notes, and snippets.

@nsantorello
Last active August 29, 2015 14:16
Show Gist options
  • Save nsantorello/8f0606a11f3591d9517b to your computer and use it in GitHub Desktop.
Save nsantorello/8f0606a11f3591d9517b to your computer and use it in GitHub Desktop.
Draws of the map of shortest tour of all public-use airports in an area with runway lengths >= X ft
(*Get all airports in an area*)GetAirports[area_]:=GeoEntities[area,"Airport"]
(*Filter to only public-use airports with at least 1 runway longer than a specified length*)
FilterPublicAirportsAndRunwayLength[airports_,rwyLen_: 3000]:=Module[{rwy},rwy=Quantity[rwyLen,"Feet"];
First[Transpose[Select[Transpose[{airports,EntityValue[airports,"LongestRunwayLength"],EntityValue[airports,"Uses"]}],#[[2]]>=rwy \[And] #[[3]][[1]]=="Public"&]]]]
(*Get the shortest tour of all the airports*)
AirportShortestTour[airports_]:= Module[{shortest},
shortest = FindShortestTour[EntityValue[airports,"Position"]];
{First[shortest], airports[[Last[shortest]]]}]
(*Get FAA identifiers for a list of airports*)
GetFAACodes[airports_]:=EntityValue[airports,"FAACode"]
(*Create a map of the shortest tour of airports in an area*)
ShortestFlightMap[area_,rwyLen_: 3000]:=Module[{airports, overlay},
airports = AirportShortestTour[FilterPublicAirportsAndRunwayLength[GetAirports[area],rwyLen]];
overlay = Graphics[{Text[Style[airports[[1]],Black,14]]},ImageSize->{100,40}];
Overlay[{GeoListPlot[airports[[2]],Joined->True,ImageSize->800,GeoLabels->True], overlay}, Alignment-> Bottom]]
@nsantorello
Copy link
Author

Creates an image of the shortest tour between all public use airports in the geographical entity with runways longer than a given distance.

Generating the map

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment