Given Lat Long, find nearest MRT (in terms of walking distance)
This repository uses OSMNX Street network to find the walking distance between coordinates (LatLong) and its nearest MRT Station.
Firstly, you would need anaconda installed. Run Anaconda prompt and run the following commands as per OSMNX's Documentation:
conda config --prepend channels conda-forge
conda create -n ox --strict-channel-priority osmnx
Once Installation is complete, run conda activate ox
to activate the enviromnent.
To check that everything is working order, run python test.py
.
If an error message along the line of ImportError: cannot import name 'gcd' from fractions'
appear, run pip install -U networkx
to upgrade networkx
library to the latest version. The error occurred due to Python version & networkx version incompatibility
This .py
script finds the walking route given a list of Latitude and Longitude .csv
file and the MRT .geojson
file, retrieved from Data.gov.sg.
Run by executing python main.py
on your python environment. A simple menu will guide you through the input of files.
NOTE: The coordinates of the routes along the shortest path is in [Lat, Long] format. If you need it to be in [Long, Lat] (i.e. Qlik GeoAnalytics) format, Open main.py
with a text editor, Change LatLong = True
to LatLong = False
.
- Input (Files must be in the same folder as
main.py
)- Coordinates
.csv
file- File must contain fields 'Latitude' and 'Longitude' header
- Example shown in
AddressMapDemo.csv
- Master Plan MRT Layer
.geojson
file- Full file from Data.gov.sg, Last updated: 09 Dec 2019
- Coordinates
- Output
- Rail station layer
.geojson
file in.csv
format- Example shown in
Pre-crawled/master-plan-2019-rail-station-layer-geojson.csv
- Example shown in
- Coordinates
.csv
file with Nearest MRT & Walking Distance appended.- Output file name will be input file name +
-WalkDist
behind, e.g. AddressMapDemo-WalkDist.csv - Example shown in
Pre-crawled/addressmap-WalkDist.csv
- Output file name will be input file name +
- Rail station layer
- 9,299 HDB Blocks with their nearest MRT, the routes & distance crawled.
- Crawled on 29 Jul 2021
- Generated by running
main.py
on the addressmap.csv, generated using my other repository Postal Code Crawler - Shortest Route is in [Long, Lat] format
- Estimated duration required: 4 hours