Lost in Yamanote!

The most important train line in Tokyo, and possibly in all of Japan, is undoubtedly the JR Yamanote Line. The Yamanote Line is a circular loop, spanning approximately 22 miles, that encompasses the core of the world's largest urban area. With millions of daily passengers, this line stands as a remarkable feat of modern infrastructure and urban planning.

Recently this piece by theguardian captured the soul and essence of this line pretty well. In this post rather, I attempt to answer the question: if an individual were to be positioned randomly within the confines of the Yamanote loop, what is the maximum direct distance to the nearest train or subway station inside the loop? Where would that position be?

ChatGPT: “The furthest points within the loop from the line itself are likely in central parts of areas such as Ueno Park or near Shinjuku Gyoen National Garden…The distance itself would be around 1.5 to 2.5 kilometers, but not more.”

The answer to this question is the dream I have of Artificial Intelligence. To be able to answer and search spatial geocoordinate data about all the encompassing stations within the boundaries of Yamanote line and produce a map of the sparsest regions that are inconveniently located from each station. Based on my knowledge, AI chat bots: such as ChatGPT and Bard, consume information from textual data, and not from other mediums such as sounds, videos, images, and maps. And they can’t answer such questions (yet!).

Pole of Inaccessiblity

A pole of inaccessibility is the farthest (or most difficult to reach) location in a given landmass, sea, or other topographical feature relative to a given criterion. The oceanic pole of inaccessibility, also known as Point Nemo, (named after a character created by Jules Verne in Twenty Thousand Leagues Under the Seas) is the place in the ocean that is farthest from land. It represents the solution to the “longest swim” problem. It is 2,688 kilometers from the nearest land. The point is so remote that at times the closest human beings are astronauts aboard the International Space Station. It would be a very unfortunate place to fall overboard there.

In the same regard Yamanote pole of inaccessibility, which is the point farthest from any station is 35°39'22.4"N 139°42'46.7"E (called ダンポロ). With the closest station being 947 meters and a 15 minute walk away. This point is more inaccessible from a station than any point in the Imperial Palace, Shinjuku Gyoen National Park, and Ueno park. The point which is in Shibuya-ku is farthest from Meguro station, Shibuya station, Hiro-o station, and Omotesando. Luckily there is a bus that goes near there frequently. This means that at approximately any point within the Yamanote Loop one at most has to walk directly around 950 meters to find a station or about 15 minutes (assuming no road closures or inaccessible areas).

Picture of me at ダンポロ

Below is the map of all the inaccessible points color coded by their distance from a station. I wish the Google Maps UI was better but the labeling is as follows:

Answering the Question!

To fully answer this question, I set out to find all the latitude and longitude of all the train and subway stations within the Yamanote Line. My first thought was to use Google Maps for this, but Google Maps was not designed to provide a range of answers given an area (Yamanote enclosing polygon). I opted to use another software called OpenStreetMaps and Overpass turbo. Overpass turbo is a query engine running on OpenStreetMaps data and can provide an answer to a lot of geospatial queries, such as:

  1. Find banks where the closest police station is more than 3km away.
  2. Find buildings where the next closest building is more than 1km away.
It was a steep learning curve to learn how to query Overpass turbo but managed to query for all the train and subway stations by box bounding the Yamanote Loop and outputing the results into a csv. My query is below:

[out:csv(name, ::lat, ::lon; false; ",")]
[timeout:60][bbox:35.611534, 139.690819, 35.745955, 139.789352];
(
  node[railway=station];
  node[station=subway];
);
out body;

Afterwards I have an approximate list of train and subway stations: name, latitude, and longitude. Based on my calculations there are around 124 subway and train stations inside the Yamanote Line.

Finding the Least Accessible Point

Hard Way (using python):

The way I approached this was for every latitude and longitude inside Yamanote I saved the direct distance to the closest train and subway station. Then I sorted the (coordinates, distance) pair by distance. This led to solving the distance and how to check if a point location is inside Yamanote. Unfortunately the area bound by Yamanote is not a square polygon. To find a point within the Yamanote line I considered using complex algorithms such as Point in Polygon. Then I decided that it is too complicated as I did not have the point coordinates around Yamanote Area and decided to simply plot them on Google Map and make a best guess. To calculate the distance of every latitude and longitude pair with every station I used the formula described at Movable Type Scripts. I pasted my code here: distance.py.

Easy Way (Overpass turbo):

After I answered the question with Python I learned more about Overpass turbo and I managed to answer the same question. The query for it is below, which lists buildings that are at least 940 meters away from each station.

[out:json][timeout:60][bbox:35.611534, 139.690819, 35.745955, 139.789352];
(
  node[railway=station];
  node[station=subway];
)->.stations;
nwr->.buildings;
nwr(around.stations:940)->.near_buildings;
(.buildings; - .near_buildings;);
out geom meta;