mirror of
https://github.com/geohacker/bmtc.git
synced 2025-12-08 18:23:31 +00:00
26 lines
1.0 KiB
Python
26 lines
1.0 KiB
Python
import json
|
|
|
|
# Find the number of routes orginating and terminating at a bus stop.
|
|
|
|
routes = json.load(open('data/routes.json', 'r'))
|
|
stops = json.load(open('data/busstops.geojson', 'r'))
|
|
o = open('data/busstops_point_stats.json', 'w')
|
|
|
|
for route in routes['features']:
|
|
origin = route['properties']['origin']
|
|
destination = route['properties']['destination']
|
|
print '# looking for: ', origin
|
|
for stop in stops['features']:
|
|
if (stop['properties']['name'] == origin):
|
|
if ('routes_originating' in stop['properties'].keys()):
|
|
stop['properties']['routes_originating'] = stop['properties']['routes_originating'] + 1
|
|
else:
|
|
stop['properties']['routes_originating'] = 1
|
|
if (stop['properties']['name'] == destination):
|
|
if ('routes_destination' in stop['properties'].keys()):
|
|
stop['properties']['routes_destination'] = stop['properties']['routes_destination'] + 1
|
|
else:
|
|
stop['properties']['routes_destination'] = 1
|
|
|
|
json.dump(stops, o)
|