This project calculates minimum walking distance (by streets/footways/paths) from houses to public transit stops.
The project has Docker containers to keep packages in them, but you can run the shell and Python scripts on their own in Linux. If you want to run it in containers, install
Also, install Git for your platform.
-
Clone the repository and enter the folder:
git clone https://github.com/culebron/stops_access.git cd stops_access
-
Download an OSM extract for your country (from GeoFabrik.de or other providers).
-
Rename/copy the
.osm.pbf
file asosm/source.osm.pbf
.
-
Create an area file, save it to osm/area.geojson
-
Run crop container:
docker-compose up crop
By default the script scripts/crop.sh
will take osm/source.osm.pbf
file, crop it and filter to keep only objects with highway
tag, and save to osm/data.osm.pbf
.
-
Build routing graph:
docker-compose up build
(Both containers exit when their scripts finish.)
How to parametrize this: if you want to have >1 areas, here are sample commands:
Cropping from custom file, by custom area and to a custom OSM file:
SOURCE=osm/my_other_file.osm.pbf AREA=osm/other_area.geojson OSM=osm/my_other_data.osm.pbf docker-compose up crop
Building routers in two different areas:
OSM=osm/file_one.osm.pbf docker-compose up build
OSM=osm/file_two.osm.pbf docker-compose up build
Running the router in one of them:
OSM=osm/file_two.osm.pbf docker-compose up backend
Launch the routing backend with a frontend by a command:
docker-compose up backend frontend
This will run both containers and block the shell. You can exit them with Ctrl+C.
Open http://localhost:9966
to see the frontend and test if routing is working.
Troubleshooting:
- if routes aren't built in your area, check where OSRM projects the points (you may have cropped it in a wrong area)
- check if frontend points at localhost and appropriate port. Open developer tools in the browser and in Network tab, see where XHR requests go.
- check if the backend router is up and running (see if
osrm-routed
process is running inhtop
, or see running containersdocker ps
) - enable requests logging in router (in
docker-compose.yml
search forNO_LOGS
) and see backend output
Running backend in background
docker-compose up -d backend [frontend]
Put houses and stops files into tmp
folder (it's mapped to /tmp
inside container).
Start calc
container and enter its bash shell:
docker-compose up -d calc
docker-compose exec calc bash
In the container:
cd /tmp
Run the script:
python3 /scripts/houses_to_stops.py houses.gpkg stops.gpkg result.gpkg
Or change max distance (in metres):
python3 /scripts/houses_to_stops.py houses.gpkg stops.gpkg result.gpkg -m 1000