Hello,
I am trying to generate isochrones using the foot-walking
profile in ORS, but ORS keeps using the driving-car
profile instead. Despite explicitly specifying the profile as foot-walking
in my Python script, the server logs and error messages indicate that ORS is trying to access the driving-car
endpoint.
Here is the error I am getting :
2025-03-23 20:29:26 [INFO] Génération des isochrones (lon, lat)
Isochrones: 0%
2025-03-23 20:29:29 [ERROR] Erreur carreau=carreau_0, coords=(55.644672,-21.388039): HTTPConnectionPool(host='localhost', port=8085): Max retries exceeded with url: /ors/v2/isochrones/driving-car/geojson (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000002AEBF6666E0>: Failed to establish a new connection: [WinError 10061] Aucune connexion n’a pu être établie car l’ordinateur cible l’a expressément refusée'))
Isochrones: 0%
2025-03-23 20:29:31 [ERROR] Erreur carreau=carreau_1, coords=(55.608041,-21.385932): HTTPConnectionPool(host=
Here is my config file :
ors:
# 1) Services configuration
services:
routing:
enabled: true
profiles:
active:
- name: foot-walking
profiles: ["foot-walking"]
# 2) Engine configuration
engine:
# Default build settings for the routing graphs
profile_default:
build:
source_file: "D:/ECOLAB/reunion-latest.osm.pbf"
# Define each profile’s details
profiles:
foot-walking:
enabled: true
# 3) API configuration
api:
host: localhost
port: 8085
# 4) Endpoints configuration
endpoints:
isochrones:
enabled: true
attribution: "openrouteservice.org, OpenStreetMap contributors"
# Increase the maximum number of intervals
maximum_intervals: 3
# Maximum number of locations in a single isochrones request
maximum_locations: 2
# Whether or not to compute the polygon area in the response
allow_compute_area: true
# Fast isochrones settings
fastisochrones:
maximum_range_distance_default: 50000
maximum_range_time_default: 18000
# 5) Logging configuration
logging:
level: INFO
and here is my code :
import os
import json
import logging
import pandas as pd
import geopandas as gpd
import geopandas as gpd
import openrouteservice
from shapely.geometry import shape
from tqdm import tqdm
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s [%(levelname)s] %(message)s',
datefmt='%Y-%m-%d %H:%M:%S'
)
############################################################
# 1) Paramètres
############################################################
profile = "foot-walking" # foot-walking, cycling-regular, etc.
geography = "reunion"
range_val = 900
interval_val = 300
ORS_URL = "http://localhost:8085/ors"
# Chemin vers shapefile en EPSG:2975
path_carreaux = r"D:\ECOLAB\GD4H\lareunion_carreaux_200m_shp\Filosofi2015_carreaux_200m_shp\Filosofi2015_carreaux_200m_reg04.shp"
# Fichier de sortie .jsonl
output_dir = "C:\\Users\\selaazdo-24\\Desktop\\out"
os.makedirs(output_dir, exist_ok=True)
output_file = f"{output_dir}\\results_{profile}_{geography}_{range_val}_{interval_val}.jsonl"
############################################################
# 2) Lecture du shapefile (EPSG:2975) et reprojection en EPSG:4326
############################################################
logging.info("Lecture du shapefile et reprojection vers EPSG:4326")
carreaus = gpd.read_file(path_carreaux)
# Reprojection -> EPSG:4326
carreaus = carreaus.to_crs(epsg=4326)
# Calcul du centroïde en WGS84
carreaus["centroid"] = carreaus.geometry.centroid
logging.info(f"Carreaux chargés : {len(carreaus)} lignes.")
############################################################
# 3) Initialisation du client ORS et vérification range
############################################################
try:
range_val = int(range_val)
interval_val = int(interval_val)
except Exception as exc:
logging.error(f"Range et interval doivent être numériques. Erreur: {exc}")
exit(1)
client = openrouteservice.Client(base_url=ORS_URL)
############################################################
# 4) Boucle : calcul des isochrones et écriture dans JSONL
############################################################
logging.info("Génération des isochrones (lon, lat)")
with open(output_file, "w", encoding="utf-8") as f_out:
for idx, row in tqdm(carreaus.iterrows(), total=len(carreaus), desc="Isochrones"):
c = row["centroid"]
if c.is_empty:
continue
# (lon, lat) = (y, x) en EPSG:4326
lon, lat = round(c.x, 6), round(c.y, 6)
# Identifiant du carreau
id_carreau = row.get("Idcar_200m", f"carreau_{idx}")
try:
resp = client.isochrones(
locations=[(lon, lat)], # OpenRouteService attend (lon, lat) en degrés
range=[range_val],
interval=interval_val
)
resp["Idcar_200m"] = id_carreau
f_out.write(json.dumps(resp) + "\n")
except Exception as e:
logging.error(f"Erreur carreau={id_carreau}, coords=({lon},{lat}): {e}")
logging.info(f"Isochrones terminées, fichier généré : {output_file}")
############################################################
# 5) Lecture du fichier JSONL et construction du GeoDataFrame
############################################################
logging.info("Lecture du fichier .jsonl et construction du GDF (EPSG:4326)")
records = []
with open(output_file, "r", encoding="utf-8") as f_in:
for line in f_in:
rec = json.loads(line.strip())
records.append(rec)
df_iso = pd.DataFrame(records)
all_features = []
for _, r in df_iso.iterrows():
if "features" in r:
for feat in r["features"]:
feat["Idcar_200m"] = r.get("Idcar_200m", None)
all_features.append(feat)
df_feats = pd.DataFrame(all_features)
df_feats["geometry"] = df_feats["geometry"].apply(lambda g: shape(g))
# Les isochrones d’ORS sont déjà en WGS84
isochrone_gdf = gpd.GeoDataFrame(df_feats, geometry="geometry", crs="EPSG:4326")
isochrone_gdf["profile"] = profile
logging.info(f"Isochrone_gdf construit avec {len(isochrone_gdf)} features !")
print(isochrone_gdf.head())
It looks like ors is set to request from /ors/v2/isochrones/driving-car/geojson even though I tries to set it for another port.
I would appreciate any help with this again. Thanks in advance