Amsterdam Transport

First, we selected the starting and ending points for our route, which were AMS Institute and the Rijksmuseum, respectively. We then identified the nearest points on the Amsterdam canals corresponding to these two locations.

import osmnx as ox
import networkx as nx
import pickle
import matplotlib.pyplot as plt
import pandas as pd

# 4.0 plotting the route
ox.config(use_cache=True, log_console=True) 
city = ox.graph_from_place('Amsterdam', retain_all=False, truncate_by_edge=False, 
                        simplify=True, custom_filter='["waterway"~"canal"]') 

# the starting and finishing point is AMS institute and the national museum
location = ox.geocode("Kattenburgerstraat 5, Amsterdam, Netherlands") 
location_to = ox.geocode("Museumstraat 1, Amsterdam, Netherlands") 
nodes = ox.distance.nearest_nodes(city, location[1], location[0], return_dist=True) 
nodes_to = ox.distance.nearest_nodes(city, location_to[1], location_to[0], return_dist=True)

# finding the route along the canal
path = ox.shortest_path(city, nodes[0], nodes_to[0]) 
# print(path)

# plotting
pt = ox.graph_to_gdfs(city, edges=False).unary_union.centroid 
bbox = ox.utils_geo.bbox_from_point(location, dist=5000) 
fig, ax = ox.plot_graph_route(city, path, bbox=bbox, show=False, close=False) 

Using these two points, we plotted the shortest path, which became the course for our activity. The path is shown in Figure 1 (luckily it’s over 5 km). Combining the knowledge from Assignments 1 and 2, we chose a route that avoided areas of poor water quality and was therefore a good choice.

Route

(Figure 1, the swimming route)

In Figure 1, the final chosen route is depicted in red, while other waterways and nodes are shown in white.

letax

# calculating the cordinates of the center point
lat = 0 
lon = 0 
for points in path: 
    lat += city.nodes[points]['x'] 
    lon += city.nodes[points]['y'] 
lat_center = lat / len(path) 
lon_center = lon / len(path) 
center_point = (lon_center, lat_center) 
print(center_point)

# plotting
ax.scatter(lon_center, lat_center, c='blue') 
plt.show()

When calculating the centre point, we added the coordinates of all points along the track and divided the sum by the number of points. This calculation yielded the corrected coordinates of the centre point, (52.36604662, 4.9001779899999995). The central point was then plotted on the map, as illustrated in Figure 2.

Spot

(Figure 2, the centre point)

2.Use the centre to find a suitable spot for the Event Headquarters.

# finding the whole map and finding the center node from the map
city_whole = (ox.graph_from_place('Amsterdam, Netherlands', simplify=True)) 
nodes_centre = ox.distance.nearest_nodes(city_whole, center_point[1], center_point[0], return_dist=True)

# plotting
pt = ox.graph_to_gdfs(city, edges=False).unary_union.centroid 
bbox = ox.utils_geo.bbox_from_point(center_point, dist=5000) 
fig, ax1 = ox.plot_graph(city_whole, bbox=bbox, show=True, close= False) 
ax1.scatter(center_point[0], center_point[1], c='blue') 
plt.show()

From the centre point, we found the nearest location on the map of Amsterdam, as shown in Figure 3. The post code of this location is 1018 DP Amsterdam and is close to Jonas Daniël Meijerplein.The area has a lot of open space, making it a viable location. In addition, it is easily accessible to all nodes on the track, making it a reasonable choice.

Spot

(Figure 3, a suitable spot)

3.Find the closest bus and tram stops at the start and finish of the swimming route. How many people can be transported within an hour.

#finding the bus and tram stops near the starting point
try: 
    bus_stop = ox.features.features_from_point(location, tags={'public_transport': 'stop_position'}, dist=500) 
    bus_stop.to_csv("bus_stop.csv") 
    print(bus_stop.name) 
except: 
    print("no station in @‘dist’ metres")

# finding the bus and tram stops near the ending point
try: 
    bus_stop_to = ox.features.features_from_point(location_to, tags = {'public_transport': 'stop_position'}, dist=500) 
    bus_stop_to.to_csv("bus_stop_to.csv") 
    print(bus_stop_to.name) 
except: 
    print("no station in @‘dist’ metres")

Initially, considering pedestrian accessibility, we searched for stations within a certain radius of the start and end points. We chose a search radius of 500 metres. Table 1 shows the list of stations collected.

Table 1

Location
Close_toBusTramNameGeometry
startyes Amsterdam, Piet HeinkadePOINT (4.9135819 52.3773362)
start yesMuziekgebouwPOINT (4.9134308 52.3772063)
start yesMuziekgebouwPOINT (4.912547 52.3772761)
start yesKattenburgerstraatPOINT (4.9211099 52.3761672)
startyes Amsterdam, KattenburgerstraatPOINT (4.9184891 52.372718)
startyes Amsterdam, KattenburgerstraatPOINT (4.9179263 52.372271)
startyes Amsterdam, IJ tunnelPOINT (4.9094406 52.3722719)
startyes Amsterdam, KattenburgPOINT (4.9205741 52.3764724)
startyes Amsterdam, Piet HeinkadePOINT (4.9140766 52.377227)
finish yesConcertgebouwPOINT (4.8796377 52.3566951)
finish yesRijksmuseumPOINT (4.887104 52.3609734)
finish yesVijzelgrachtPOINT (4.8909623 52.3599031)
finish yesConcertgebouwPOINT (4.8795995 52.3560193)
finish yesMuseumpleinPOINT (4.8812446 52.358854)
finish yesVijzelgrachtPOINT (4.8921024 52.3595051)
finish yesConcertgebouwPOINT (4.8791804 52.3559245)
finish yesConcertgebouwPOINT (4.8798 52.3564107)
finishyes Amsterdam, LeidsepleinPOINT (4.8806142 52.3625646)
finish yesLeidsepleinPOINT (4.8830722 52.3634714)
finish yesVijzelgrachtPOINT (4.8910303 52.3600132)
finish yesVan BaerlestraatPOINT (4.878318 52.3584538)
finish yesVan BaerlestraatPOINT (4.8781266 52.3587793)
finish yesLeidsepleinPOINT (4.8829633 52.3642229)
finish yesRijksmuseumPOINT (4.8873395 52.3608307)
finishyes Amsterdam, Ferdinand BolstraatPOINT (4.8918514 52.3579917)
finishyes Amsterdam, LeidsepleinPOINT (4.8810441 52.3620635)
finishyes Amsterdam, RuysdaelkadePOINT (4.8865615 52.3602454)
finishyes Amsterdam, RuysdaelkadePOINT (4.8865688 52.3603257)
finishyes Amsterdam, Ferdinand BolstraatPOINT (4.8923047 52.3579616)
finish yesMarie HeinekenpleinPOINT (4.8907033 52.3570037)
finish yesMarie HeinekenpleinPOINT (4.8907718 52.3571177)
finish yesLeidsepleinPOINT (4.8810698 52.3632085)
finishyes ConcertgebouwPOINT (4.8785466 52.3554983)
finishyes VijzelgrachtPOINT (4.8910469 52.3606866)
finishyes VijzelgrachtPOINT (4.8912207 52.3606661)
finish yesVijzelgrachtPOINT (4.8925358 52.3594772)
finishyes Amsterdam, LeidsepleinPOINT (4.8809776 52.3631402)
finish yesWeteringcircuitPOINT (4.8923379 52.3593327)
finishyes ConcertgebouwPOINT (4.8795913 52.3560311)
finishyes ConcertgebouwPOINT (4.8796233 52.3566894)
finishyes ConcertgebouwPOINT (4.8798146 52.3564161)
finish yesMuseumpleinPOINT (4.8806042 52.3587143)
finish yesMuseumpleinPOINT (4.880612 52.3586985)
finishyes Amsterdam, MuseumpleinPOINT (4.8808204 52.3586774)

In the estimation, we have assumed an average arrival frequency of 5 buses per hour and 4 trams per hour (source: Public transport in Amsterdam). In addition, we estimate that the maximum capacity of each bus is 30 passengers and that of each tram is 50 passengers. Based on these rough estimates, we can calculate that the maximum interchange capacities of the stations near the origin and the terminus in an hour are 1,150 and 6,450 respectively.

4.Can you find which bus and tram lines these are, and can you find their routes?

# finding the bus route,but the code is not showing any route, reason unknown
tags = {'route': 'bus'}
gdfox = ox.features_from_point(location_to, tags, dist=1000)
print(gdfox)

Closeness centrality measures how easily a node can reach other nodes in a network. It’s used to determine the point’s accessibility within a network. Nodes with high closeness centrality are closer, in terms of network connections, to other nodes. In a geographic context, this reflects that these points are more accessible, similar to how central locations in a city are more easily reachable from other places. Therefore, we choose closeness centrality to give support evidence for the choosing of the points.

# finding the map
graph = ox.graph_from_point(center_point, dist=5000)

# finding the nodes close to the start/center/end point
nodes = ox.distance.nearest_nodes(graph, location[1], location[0], return_dist=True)
nodes_to = ox.distance.nearest_nodes(graph, location_to[1], location_to[0], return_dist=True)
nodes_cen = ox.distance.nearest_nodes(graph, center_point[1], center_point[0], return_dist=True)

# calculate centrality
start_centrality = nx.closeness_centrality(graph, nodes[0])
cen_centrality = nx.closeness_centrality(graph, nodes_cen[0])
end_centrality = nx.closeness_centrality(graph, nodes_to[0])
print(start_centrality,cen_centrality,end_centrality)
PointNode
Start point0.014975167550752658
Center point0.016698413110206794
End point0.014168299848680767

The results are largely consistent with our expectations. The center point is indeed closer to the center of Amsterdam, which makes it more accessible to other points on the map. However, it’s important to note that the calculated results can vary based on factors such as the selected map size and the parameters used, including the choice of the center point.

6.Find all cafes, restaurants near the finish line. Walking time smaller than 10 minutes.

# finding the map near the ending point
plt.close('all') 
graph = ox.graph_from_point(location_to, dist=2100)

# extracting all the cafes and restaurants within 750 radius
poi = ox.features.features_from_point(location_to, tags={'amenity': ['cafe','restaurant']}, dist=750) 
target_node = ox.distance.nearest_nodes(graph, location_to[1], location_to[0], return_dist=True) 
pt = ox.graph_to_gdfs(city_whole, edges=False).unary_union.centroid 
bbox = ox.utils_geo.bbox_from_point(location_to, dist=2100) 
fig2, ax2 = ox.plot_graph(city_whole, bbox=bbox, show=False, close=False)

# examine the shortest distance, if it is within 10 minutes walk(750m)
name = []
i = 0
for row in poi.T.T.itertuples():
    try:
        orig = getattr(row, 'geometry')
        name1 = getattr(row, 'name')
        orig_node = ox.distance.nearest_nodes(graph, orig.x, orig.y, return_dist=True)
        length = nx.shortest_path_length(G=graph, source=orig_node[0], target=target_node[0], weight='length')
        if length <750:
            name.append(name1)
            ax2.scatter(orig.x, orig.y, c='blue')
            i += 1
            if i == 1:
                listing1 = pd.DataFrame(
                    {"amenity":[getattr(row, 'amenity')],"length":[length],"name":[getattr(row, 'name')],
                     "geometry":[getattr(row, 'geometry')],"description":[getattr(row, 'description')]})
            else:
                listing = pd.DataFrame(
                    {"amenity": [getattr(row, 'amenity')], "length": [length], "name": [getattr(row, 'name')],
                     "geometry": [getattr(row, 'geometry')], "description": [getattr(row, 'description')]})
                listing1 = pd.concat([listing1, listing], ignore_index=True)

    except:
        pass
listing1.to_csv("listing.csv")

# plotting
plt.show() 
plt.savefig("4.jpg") 
print(name)

Cafe

(Figure 4, all nearby cafes and restaurants)

Table 2

numamenitylengthnamegeometry
1restaurant703.303WaaghalsPOINT (4.889014 52.3571286)
2cafe644.229Café AmericainPOINT (4.8813718 52.3638967)
3restaurant542.675Bollywood Indian RestaurantPOINT (4.8844033 52.3639694)
4restaurant542.675Puri Mas Indonesisch RestaurantPOINT (4.8845382 52.3641036)
5restaurant625.788Brasserie KeyzerPOINT (4.8792088 52.3568126)
6restaurant545.967Small TalkPOINT (4.878408 52.3579755)
7restaurant703.303ISSHINPOINT (4.8886451 52.3570377)
8restaurant425.239OtaruPOINT (4.8888704 52.3584175)
9restaurant311.648Sama SeboPOINT (4.8831414 52.3606764)
10restaurant557.641MaxiesPOINT (4.8797621 52.3600875)
11restaurant430.877Hard Rock CafePOINT (4.8833077 52.3621869)
12restaurant605.926HosokawaPOINT (4.8827502 52.3629202)
13restaurant430.266WagamamaPOINT (4.8831541 52.3625079)
14restaurant430.877Maximus Steak HousePOINT (4.8834726 52.3622945)
15restaurant520.712De BaliePOINT (4.883101 52.36312)
16cafe694.408StarbucksPOINT (4.8836352 52.3645106)
17cafe584.227Superskunk CoffeeshopPOINT (4.8851485 52.3642612)
18restaurant542.675PiccolinoPOINT (4.8852731 52.3636053)
19restaurant353.062MomoPOINT (4.8825862 52.3615027)
20restaurant511.865OmaPOINT (4.8851836 52.3630587)
21restaurant634.081Stoop & Stoop EetcaféPOINT (4.8838952 52.3642795)
22restaurant634.081Pancake Corner RestaurantPOINT (4.88345 52.3640344)
23restaurant522.801Palladium Restaurant ClubPOINT (4.8835286 52.3635772)
24restaurant652.319Nam KeePOINT (4.8911961 52.3574253)
25restaurant677.521de OesterbarPOINT (4.8827741 52.3647013)
26restaurant542.675Antonio’s RestaurantePOINT (4.88489 52.3636482)
27restaurant542.675BojoPOINT (4.8847921 52.3639322)
28restaurant542.675Chicano’sPOINT (4.8847449 52.363749)
29restaurant511.865De blauwe HollanderPOINT (4.8847235 52.3635484)
30restaurant542.675El RanchoPOINT (4.8845402 52.3638816)
31restaurant694.408GreekPOINT (4.8841943 52.3643571)
32restaurant694.408Los AmigosPOINT (4.8842525 52.3642942)
33restaurant634.081MimoPOINT (4.8843814 52.3642096)
34restaurant542.675MykonosPOINT (4.8846815 52.3640102)
35restaurant694.408O’ Sole MioPOINT (4.8841433 52.3644198)
36restaurant511.865PeppinoPOINT (4.8846075 52.3634912)
37restaurant694.408PisaPOINT (4.8839811 52.3644852)
38restaurant634.081Royal ThaiPOINT (4.8842311 52.3641259)
39restaurant542.675TapasPOINT (4.8849795 52.3637854)
40restaurant511.865Mr Tong’sPOINT (4.8848237 52.3633343)
41restaurant542.675Zorba de GriekPOINT (4.8851083 52.3637257)
42restaurant634.081Do BrasilPOINT (4.8840332 52.3641938)
43restaurant511.865il PalioPOINT (4.8849115 52.3633969)
44restaurant511.865MamaPOINT (4.8846914 52.3631784)
45restaurant511.865Ceppi’sPOINT (4.8850519 52.3628586)
46restaurant542.675El Patio GranadaPOINT (4.8854166 52.3635176)
47restaurant511.865LeeuwPOINT (4.8848025 52.3630944)
48restaurant511.865MadrasPOINT (4.8848499 52.3630641)
49restaurant511.865MayaPOINT (4.8844538 52.3636051)
50restaurant338.413MayurPOINT (4.8861759 52.3623426)
51restaurant509.305In de BuurtPOINT (4.8845121 52.3630261)
52restaurant542.675Porto CarraraPOINT (4.8852647 52.3634013)
53restaurant511.865SherpaPOINT (4.8847519 52.3631367)
54restaurant511.865Taste of CulturePOINT (4.8851368 52.3631049)
55restaurant542.675El VinoPOINT (4.8848889 52.3639005)
56restaurant542.675GranadaPOINT (4.8853422 52.3636437)
57restaurant584.227Japan InnPOINT (4.8854331 52.3638952)
58restaurant542.675Los ArgentinosPOINT (4.8854787 52.3637143)
59restaurant542.675Moshi MoshiPOINT (4.8854104 52.36368)
60restaurant694.408The Guru of IndiaPOINT (4.8828626 52.3650182)
61restaurant491.747Pancake CornerPOINT (4.8838974 52.3628007)
62restaurant697.253De SmoeshaanPOINT (4.8805712 52.3640307)
63restaurant731.813Café LoetjePOINT (4.8842366 52.3543672)
64restaurant207.754SrikandiPOINT (4.8836467 52.3614794)
65restaurant634.081Maximus Pizzeria - SteakhousePOINT (4.8836566 52.3641394)
66restaurant677.521SumoPOINT (4.882715 52.3647599)
67restaurant643.662KaasbarPOINT (4.8905157 52.3572817)
68restaurant698.081Yuan’s Hot PotPOINT (4.8904953 52.3570239)
69restaurant652.319TajPOINT (4.891031 52.3574228)
70restaurant724.995SimpelPOINT (4.8907851 52.3565041)
71restaurant724.995Soju BarPOINT (4.8907691 52.3564272)
72restaurant724.995The Seafood BarPOINT (4.8904068 52.3564701)
73restaurant718.614Monte VerdePOINT (4.8872973 52.3547524)
74restaurant700.448De kleine ValkPOINT (4.891505 52.3573485)
75restaurant718.614JuulsPOINT (4.8874016 52.3547449)
76restaurant475.684Lombardo’sPOINT (4.8887021 52.3635469)
77cafe475.684Stach cafePOINT (4.8884551 52.3633122)
78cafe584.227Bocca Coffee RoastersPOINT (4.8868127 52.3644463)
79cafe634.081Satellite SportscafePOINT (4.8834687 52.3640476)
80restaurant511.865PicchinoPOINT (4.8849034 52.3632077)
81cafe542.675Cafe het HokPOINT (4.8851645 52.363487)
82restaurant542.675Mama ImpastoPOINT (4.8850062 52.3634868)
83restaurant542.675EetcaféPOINT (4.8848555 52.3635486)
84restaurant509.305CastellPOINT (4.8848679 52.3628166)
85restaurant509.305Restaurant DubbelPOINT (4.8850714 52.3627171)
86cafe624.961Café|Brasserie StadsschouwburgPOINT (4.882281 52.3639853)
87restaurant338.413Winebar ShirazPOINT (4.8857879 52.3623691)
88restaurant430.266The Avocado ShowPOINT (4.8835362 52.3625483)
89cafe584.227Coffeeshop EasytimesPOINT (4.8850229 52.3643312)
90restaurant584.227Poké PerfectPOINT (4.8857331 52.3638861)
91cafe474.842B&BPOINT (4.8824617 52.3623251)
92restaurant542.675Tacos & TequilaPOINT (4.8855319 52.3634016)
93restaurant205.118Le Rendez-vousPOINT (4.8863852 52.361421)
94restaurant694.408Full Moon GardenPOINT (4.883854 52.3646327)
95cafe658.512Village BagelsPOINT (4.8920333 52.3623655)
96restaurant600.187CarrouselPOINT (4.891748 52.3589849)
97restaurant693.674MyrabellePOINT (4.8918915 52.3619155)
98restaurant681.735Piet de LeeuwPOINT (4.8921422 52.361512)
99restaurant681.735Sukhothai ThaneePOINT (4.8924177 52.3614727)
100cafe608.813Bar DoPOINT (4.8915062 52.3609252)
101restaurant608.813Proper. IndofoodPOINT (4.8914637 52.3607992)
102restaurant608.813SUSHI GKPOINT (4.8914356 52.3606912)
103restaurant567.575IboendaPOINT (4.8914217 52.3606013)
104cafe384.402Back to Black coffee bar and roasteryPOINT (4.8885688 52.3610387)
105cafe567.575Luuk’sPOINT (4.8913927 52.3605653)
106restaurant403.134LevantPOINT (4.8873509 52.361025)
107restaurant745.257Oresti’s TavernaPOINT (4.8783821 52.3634426)
108restaurant578.59Pompa Tapas BarPOINT (4.8779295 52.3581174)
109cafe578.59The Coffee DistrictPOINT (4.8776367 52.3580174)
110restaurant404.016PatouPOINT (4.8813254 52.3602398)
111restaurant662.271L’ Entrecote et les damesPOINT (4.8805264 52.3556659)
112restaurant662.271BoufPOINT (4.8805564 52.3556121)
113restaurant743.492AnjapparPOINT (4.8806241 52.3548123)
114restaurant703.303RainbowlPOINT (4.8886429 52.3569857)
115restaurant703.303Van ‘t SpitPOINT (4.888619 52.3567873)
116cafe643.662Bakers & RoastersPOINT (4.8899479 52.3572951)
117restaurant511.865Chicanos / Tex MexPOINT (4.8843666 52.3636279)
118restaurant589.052SoloPOINT (4.8803931 52.3560295)
119restaurant475.684Vatten RamenPOINT (4.888799 52.3633111)
120restaurant516.948TaikoPOINT (4.87924 52.3585627)
121restaurant603.921La Storia della VitaPOINT (4.8922941 52.3596722)
122cafe151.799 POINT (4.8857446 52.3597769)
123restaurant595.333San GeorgePOINT (4.8796087 52.3629726)
124cafe502.485Restaurant StedelijkPOINT (4.8794436 52.3574939)
125restaurant473.36Buffet van OdettePOINT (4.8889892 52.3622855)
126restaurant35.034RijksPOINT (4.8842926 52.3595984)
127restaurant576.097Lavinia Good FoodPOINT (4.8898054 52.3631654)
128restaurant662.271MartinotPOINT (4.8806877 52.3555304)
129restaurant677.521New York SteakhousePOINT (4.8831308 52.364509)
130restaurant542.675The PantryPOINT (4.8849563 52.3634594)
131restaurant718.614IzakayaPOINT (4.8875769 52.3545104)
132cafe634.081Easy Internet CafePOINT (4.8837681 52.3640142)
133cafe643.662Bakers & RoastersPOINT (4.889846 52.3573122)
134restaurant647.235SiriphonPOINT (4.8898758 52.3575399)
135cafe632.032Corner Bakery AmsterdamPOINT (4.8840259 52.3547327)
136cafe511.865The RookiesPOINT (4.8852296 52.3629689)
137restaurant509.305SumoPOINT (4.8838817 52.3633312)
138cafe658.512de FlesPOINT (4.892228 52.3623331)
139cafe354.039brasserie zuiderbadPOINT (4.8860801 52.357493)
140restaurant368.975Le TambourinPOINT (4.881202 52.3582777)
141restaurant698.081Yuan’s Hot PotPOINT (4.8905324 52.3569617)
142restaurant703.467Padina BarPOINT (4.893177 52.357783)
143restaurant546.04The Pancake ClubPOINT (4.8813295 52.3626071)
144restaurant700.448Vegan Junk Food BarPOINT (4.8916033 52.3572501)
145restaurant664.529Kailash ParbatPOINT (4.8924555 52.3596549)
146restaurant724.995The Beefsteak ClubPOINT (4.8904706 52.3565873)
147cafe710.476café De TulpPOINT (4.8916761 52.3569168)
148cafe164.562Kiosk Rembrandt Van GoghPOINT (4.8831125 52.3592175)
149restaurant658.512Tokyo RamenPOINT (4.8920385 52.3624137)
150restaurant714.409Eggs BenaddictedPOINT (4.8849343 52.3643939)
151restaurant511.865Pier 62POINT (4.8847851 52.3631098)
152restaurant694.408GandhiPOINT (4.8829781 52.3649437)
153cafe548.835Chimney Cake Bakery & CaféPOINT (4.879167 52.356934)
154cafe408.368BlushingPOINT (4.8803835 52.3587949)
155restaurant743.492AnjapparPOINT (4.8806009 52.3547972)
156cafe714.409Eggs BenaddictedPOINT (4.884987 52.3643561)
157restaurant686.907ANPOINT (4.8937415 52.3593592)
158restaurant694.408 POINT (4.8840819 52.3644521)
159restaurant542.675Hongdae AmsterdamPOINT (4.8848957 52.3638537)
160restaurant703.467 POINT (4.8931742 52.35772)
161restaurant717.7JoostPOINT (4.8780303 52.3625932)
162restaurant487.423Grand Café LidoPOINT (4.8819472 52.3625269)
163cafe634.081Get DownPOINT (4.8838071 52.3639818)