VIA Rail uses its own 4-letter codes for stations, but isn't publishing their data (yet). This aims to provide the missing data for VIA's stations.
A list of VIA's own station data, obtained letter by letter using the http://reservia.viarail.ca/GetStations.aspx?q=<letter> endpoint (used for their reservation portal live search). Each entry looks like:
{
"sc": "ABBO",
"pv": "BC",
"sn": "ABBOTSFORD",
"dEn": "ABBOTSFORD"
}
Where:
sc: Stands for "station code"pv: Stands for "province"sn: Stands for "station name"dEn: Not sure—however it is the same assnfor all entries
Same as stations_via.json plus some extra data fetched for each station by parsing http://www.viarail.ca/en/embedded/station/detail/<station code>, when available. Each entry looks like:
{
"sc": "ABBO",
"sn": "ABBOTSFORD",
"pv": "BC",
"dEn": "ABBOTSFORD",
"name": "Abbotsford train station",
"address": "Hargitt Street, Abbotsford, BC, V3G 1M8, Canada",
"city": "Abbotsford",
"lat": "49.116845",
"long": "-122.277756",
"url": "http://www.viarail.ca/en/embedded/station/detail/ABBO",
"timezone": "America/Vancouver"
}
Where:
name: The long name of the station.lat: The latitude of the station, in decimal degrees.long: The Longitude of the station, in decimal degrees.address: The full address of the station.url: The URL to get the full station information.
Notes:
- Any of the above can be an empty string when the information was not available.
- Some of these stations are really obscure and are not passenger stations. Little information is available for these.
pip install -r requirements
To add support for timezones run:
pip install git+https://github.com/pegler/pytzwhere.git
Then:
>>> from via_rail import VIA
>>> VIA().save_stations(filename='stations_via.json')
Or:
>>> VIA().save_stations(filename='stations_via_full.json', full=True)