Isochrone API that provides a functionality of calculating isochrones (walking areas).
- Download graph for regions where you need to calculate isochrones. Download
.osm.pbf
files from http://download.geofabrik.de/. - Put your
.osm.pbf
. files undercontainers/app/osm/pbf
directory (currently there isrutland-latest.osm.pbf
for illustration reasons, remove it if you don't need this area). - Run
docker-compose up --build
(Hints on how-to installdocker
anddocker-compose
)
Then, you'll need to wait until graph is uploaded to DB. During upload, you might see messages like this docker-compose logs app
:
[| ] (1%) Total processed: 20000 Vertices inserted: 58672 Split ways inserted 53186
[*| ] (3%) Total processed: 40000 Vertices inserted: 48981 Split ways inserted 46608
[**| ] (5%) Total processed: 60000 Vertices inserted: 46003 Split ways inserted 43317
[***| ] (6%) Total processed: 80000 Vertices inserted: 33135 Split ways inserted 34595
[****| ] (8%) Total processed: 100000 Vertices inserted: 16320 Split ways inserted 18170
When API is ready you'll see message like this docker-compose logs app
:
* Serving Flask app "app" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://0.0.0.0:1769/ (Press CTRL+C to quit)
In order to calculate isochrone you need to pass 3 query parameters
to API:
X
(float) - Longitude of a point for which you want to calculate walking area.Y
(float) - Latitude of a point for which you want to calculate walking area.sec
(integer) - Number of seconds (600 - 10 minute walking area, 300 - 5 minute walking area, etc.)
import requests
url = 'http://localhost:1769/isochrone?'
params = {'X': -0.1946611966680779, 'Y': 51.46534965585685, 'sec': 300}
resp = requests.get(url, params=params)
print(resp.json())
POLYGON((-0.200436112629018 51.4667218592721,-0.200446733267529 51.4667235969986,-0.200460738988607 51.466725888585,-0.200490282193392 51.4667307223818, ...))