New York City Subway Stations

This Demonstration plots all the stations on a selected subway line, marking the two stations closest to each other in orange and the stations farthest apart in red. All stations are identified with tooltips. The map includes stations that are accessible only by pedestrian tunnels, though these are screened out before the minimum distance calculation is performed.



  • [Snapshot]
  • [Snapshot]
  • [Snapshot]


For the sake of loading speed and to eliminate dependencies on outside files not allowed in Demonstrations, I have initialized this Demonstration with precomputed station locations and the distances between every pair of stations for each subway line.
I used borough outlines from [1] and subway station locations from [2]. I found three potentially tricky elements to the calculation — first, the city provides locations for subway entrances but not subway platforms, and the entrances are not necessarily centered around the platform; I chose a single entrance arbitrarily for each station and if I chose an outlying one, it will introduce a small error in the result. Second, the subway entrance locations are in {latitude, longitude} format (actually, {latitude, longitude} × 1,000,000), and this is the order expected by Mathematica's GeoDistance function, but the basemap is formatted in {longitude, latitude} format, so we have to reverse the order of the elements in each location when we switch between mapping and determining distances. Third, the city's database of subway entrances identifies an entrance as pertaining to a given line even if it is connected to that line only by an underground pedestrian tunnel. Since for the purposes of my distance calculations, I cared about what the trains are doing only, these extra stations had to be screened out before that computation was run.
Rather than checking only adjacent stations on each line for the closest stations, and only the ends of each line for the most distant points visited by a given train, I had Mathematica check all possible permutations of stations on each line. As it turned out, the nearest stations were always adjacent, but the farthest ones were not necessarily line-ends. See the M train, for example.
[1] Baruch College CUNY. "New York Metropolitan ACS Geodatabase." http://www.baruch.cuny.edu/geoportal/nyc_gdb/.
[2] Metropolitan Transportation Authority. "Subway Entrance and Exit GIS Data." mta.info/developers/sbwy_entrance.html.
    • Share:

Embed Interactive Demonstration New!

Just copy and paste this snippet of JavaScript code into your website or blog to put the live Demonstration on your site. More details »

Files require Wolfram CDF Player or Mathematica.

Mathematica »
The #1 tool for creating Demonstrations
and anything technical.
Wolfram|Alpha »
Explore anything with the first
computational knowledge engine.
MathWorld »
The web's most extensive
mathematics resource.
Course Assistant Apps »
An app for every course—
right in the palm of your hand.
Wolfram Blog »
Read our views on math,
science, and technology.
Computable Document Format »
The format that makes Demonstrations
(and any information) easy to share and
interact with.
STEM Initiative »
Programs & resources for
educators, schools & students.
Computerbasedmath.org »
Join the initiative for modernizing
math education.
Step-by-Step Solutions »
Walk through homework problems one step at a time, with hints to help along the way.
Wolfram Problem Generator »
Unlimited random practice problems and answers with built-in step-by-step solutions. Practice online or make a printable study sheet.
Wolfram Language »
Knowledge-based programming for everyone.
Powered by Wolfram Mathematica © 2017 Wolfram Demonstrations Project & Contributors  |  Terms of Use  |  Privacy Policy  |  RSS Give us your feedback
Note: To run this Demonstration you need Mathematica 7+ or the free Mathematica Player 7EX
Download or upgrade to Mathematica Player 7EX
I already have Mathematica Player or Mathematica 7+