Group Abstract Group Abstract

Message Boards Message Boards

3D visualization of the Tokyo subway system

Posted 6 years ago
Attachments:
POSTED BY: Kotaro Okazaki
5 Replies

Nice post! I'm not sure I entirely understand how you converted the PixelValuePositions results to lat-long, but you may be interested in a function in the Function Repository called OSMImport (https://resources.wolframcloud.com/FunctionRepository/resources/OSMImport).

OSMImport lets you import GIS data from OpenStreetMap, which almost certainly includes subway routes. I'm not sure if it would include depth, but if nothing else it would get you the lat-long coordinates for the routes.

Edit:

Here is an example. First, we get the OSM data for some region in Tokyo:

osm=ResourceFunction["OSMImport"][GeoBoundsRegion[{{35.695217,35.705217},{139.756822,139.766822}}]];

This use of OSMImport uses the OSM API, which is very limited in how much it can return (I think it's no more than 50,000 objects, which is quickly used up in even a small region of well-covered cities). If you wanted to do all of Tokyo, you can use a separate API to download the XML files for the whole city and then import then using OSMImport.

First, we can look at some of the railway-related Nodes:

Select[osm["Nodes"], KeyExistsQ[#Tags, "railway"] &]

which returns things like

<|"2559434143" -> <|"Position" -> GeoPosition[{35.6996, 139.765}], 
  "Tags" -> <|"maxspeed" -> "95", "name" -> "????", 
    "name:en" -> "Ochanomizu", "name:es" -> "Ochanomizu", 
    "name:fr" -> "Ochanomizu", "name:ja" -> "????", 
    "name:ja_kana" -> "??????", "name:ja_rm" -> "Ochanomizu", 
    "name:ko" -> "?????", "name:ru" -> "??????????", 
    "operator" -> "???????", "public_transport" -> "station", 
    "railway" -> "station", "source" -> "Bing, 2007-04", 
    "train" -> "yes", "wheelchair" -> "limited", 
    "wikidata" -> "Q801289", 
    "wikipedia" -> "ja:?????"|>|>, "2559434708" -> <|"Position" -> 
   GeoPosition[{35.7002, 139.763}], 
  "Tags" -> <|"railway" -> 
     "switch"|>|>, "4855419881" -> <|"Position" -> 
   GeoPosition[{35.6959, 139.757}], 
  "Tags" -> <|"name" -> "???", "name:en" -> "Jimbocho", 
    "name:es" -> "Jimbocho", "name:ja" -> "???", 
    "name:ja_kana" -> "???????", "name:ja_rm" -> "Jimb?ch?", 
    "name:ko" -> "???", "name:ru" -> "????????", "name:zh" -> "????", 
    "network" -> "?????????", "operator" -> "?????", 
    "public_transport" -> "stop_position", "railway" -> "stop", 
    "ref" -> "Z07", "subway" -> "yes", 
    "website" -> 
     "https://www.tokyometro.jp/lang_en/station/jimbocho/", 
    "wikidata" -> "Q76805", 
    "wikipedia" -> "ja:????"|>|>, "6070813705" -> <|"Position" -> 
   GeoPosition[{35.6996, 139.765}], 
  "Tags" -> <|"loc_ref" -> "2", "name" -> "????", 
    "name:en" -> "Ochanomizu", "name:es" -> "Ochanomizu", 
    "public_transport" -> "stop_position", "railway" -> "stop", 
    "train" -> "yes"|>|>,...|>

I haven't read through the full results, but I don't think it contains depth.

However, for the lat-long data, you can use the Ways parameter to get something like this:

GeoGraphics[{Thick,Red,Line@Values@osm[["Nodes",#Nodes,"Position"]]&/@Select[osm["Ways"],KeyExistsQ[#Tags,"railway"]&]}]

trains in Tokyo

All of those routes are also internally tagged with properties like their name, gauge, max speed, operator, track voltage, passenger vs freight, etc.

Thanks for your fruitfull information.

Based on it, I tried to find the exact route of Hanzomon Line. Because it does not work well for a wide region, I decided to get a route between adjacent stations.

There are 14 stations on Hanzomon Line.

hanzomonStations = {{35.658517`, 139.701334`}, {35.665247`, 
    139.712314`}, {35.672765`, 139.724159`}, {35.678757`, 
    139.740258`}, {35.685703`, 139.741644`}, {35.695589`, 
    139.751948`}, {35.695492`, 139.75812`}, {35.684801`, 
    139.766086`}, {35.684888`, 139.773161`}, {35.682061`, 
    139.786035`}, {35.682105`, 139.798851`}, {35.689071`, 
    139.815651`}, {35.696437`, 139.813949`}, {35.710702`, 
    139.812935`}};
hanzomonStationsPair = Transpose /@ Partition[hanzomonStations, 2, 1];

At first, it works well between Shibuya station(1st) and Omote-sando station(2nd).

osm = ResourceFunction["OSMImport"][
   GeoBoundsRegion[hanzomonStationsPair[[1]]]];
railway = Select[osm["Ways"], KeyExistsQ[#Tags, "railway"] &]; pos = 
 Select[railway, MemberQ[#[[2]], "Tokyo Metro Hanzomon Line"] &];
GeoGraphics[{Thick, Red, 
  Line@Values@osm[["Nodes", #Nodes, "Position"]] & /@ pos}]

enter image description here

However, it doesn't work well between Omote-sando station(2nd) and Aoyama-itchome station(3rd). enter image description here

POSTED BY: Kotaro Okazaki

What a fascinating insight into the design of transportation systems in Japan, thanks for sharing! Where did you find the depth of subway stations information?

POSTED BY: Vitaliy Kaurov

Thanks a lot. I wanted to get the depth of subway stations information with Web scraping. However, I was not able to find them. Finally I've got them from the book(Japanese).

POSTED BY: Kotaro Okazaki

enter image description here - Congratulations! This post is now a Staff Pick as distinguished by a badge on your profile! Thank you, keep it coming, and consider contributing your work to the The Notebook Archive!

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