Skip to content

About

Master's thesis: builds Deterministic Operating Cycle (DOC) road models from GPS traces via the HERE API for vehicle energy & range estimation

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

Estimation of Accurate Path Length with Geospatial Data Analysis (dOC Model)

Python HERE API Pandas Report

This repository holds the code for my Master's thesis in Mechatronics Engineering, "Estimation of Accurate Path Length with Geospatial Data Analysis". I carried out the work at Chalmers University of Technology (Vehicle Engineering & Autonomous Systems), and it was published there as a technical report.

The tool turns raw GPS traces from a vehicle into a Deterministic Operating Cycle (dOC) model: a distance-indexed description of the road (elevation, gradient, curvature, speed limits, traffic signs, weather) that can be used for energy-consumption analysis and residual range estimation.

📄 Read the report: research.chalmers.se/publication/541772 · Full text (PDF)


Research

Accurate path length is the foundation of residual range prediction for electric and smart vehicles. The thesis compares several distance-estimation methods (Haversine, Spherical Law of Cosines, Geodesic, and new elevation-embedded variants) on real road data from flat and hilly routes. It measures both accuracy against ground truth and computation time. The flat route is the Stockholm Marathon course, and the hilly route is the Tour de France stage from Nice to Col de la Couillole.

Method Error, flat route Error, hilly route Compute time Best for
Vincenty variant 0.008 % 0.10 % 0.01 – 0.03 s High-precision range prediction
Geodesic 0.07 % 0.21 % (with elevation) 0.40 – 1.20 s High accuracy when compute is available
Haversine / Spherical Law of Cosines ~0.31 % ~0.61 – 0.63 % 0.005 – 0.02 s Fast, moderate-accuracy estimates

The dOC model was then generated and validated on real routes, including Lund → Malmö (short) and Oslo → Bergen (long). It was also tested for robustness with noise injected into the GPS input.

Author Yogeswaran Amsavalli
Supervisor Carl Emvin, Chalmers University of Technology
Degree MSc Mechatronics Engineering, University of Trento & Budapest University of Technology and Economics
Published Chalmers technical report, 2024 (Dept. of Mechanics and Maritime Sciences)
Keywords dOC, path length estimation, road data

How it works

GPS trace (.txt)  ──►  HERE Route Matching API  ──►  JSON road attributes
                                                          │
                     DOC model (.csv) + path plot  ◄──  clean, align, compute distances
  1. Read latitude/longitude points from a text file.
  2. Match the trace to the road network with the HERE Route Matching v8 API, requesting ADAS, speed-limit, traffic-sign, traffic-pattern and archived-weather attributes.
  3. Parse the JSON response (jsonpath-ng) and snap the returned link geometry to the input points.
  4. Compute cumulative distance between consecutive points (Haversine and geodesic/Vincenty via pyproj).
  5. Clean missing values (e.g. fill speed limits from neighbouring links and free-flow speed).
  6. Export the DOC model as CSV, along with a report and a plot of the vehicle path.

Getting started

git clone https://github.com/YogiOnCode/DOC_model_road_data_tool.git
cd DOC_model_road_data_tool
pip install -r requirements.txt

You need a HERE developer API key.

  1. In DOC_Model.py, set api_key to your HERE API key.
  2. Set input_directory (at the bottom of the file) to a folder containing your .txt GPS traces. Output is written to the same folder by default (output_directory).
  3. Run:
python DOC_Model.py

Every .txt file in the input folder is processed.

Input format

Latitude, Longitude
47.37532819752522, 8.588794536964125
45.458435679351616, 9.185317763784466

See sample_input.txt.

DOC output

Attribute Description
Distance (m) Cumulative geodesic distance along the route.
Latitude / Longitude (deg) High-precision WGS84 coordinates along each link.
Elevation (m) Height above the WGS84 ellipsoid.
Gradient (deg) Vertical road direction; missing values are set to 0.
Heading (deg) Horizontal road heading; missing values are set to 0.
Curvature (1/m) 1 / radius at each point; missing values are set to 0.
Speed limit (m/s) Applicable speed limit; gaps filled from adjacent links and free-flow speed.
Free-flow speed (m/s) Static average travel speed for the link.
Traffic signal, Stop, Yield, Pedestrian crossing Binary flags for signs present on the link.
Wind direction (deg) / Wind velocity (m/s) From archived weather data (nullable).

dOCformat.pdf documents the format, and Illustration.pdf shows an example.

Applications

  • Residual range estimation: how far the vehicle can travel on its remaining battery or fuel.
  • Energy consumption analysis: using accurate distance plus road gradient, curvature and speed profile.
  • Simulation and testing: realistic road conditions for vehicle-dynamics simulations.

Tech stack

Python · pandas · NumPy · pyproj · haversine · jsonpath-ng · Matplotlib · Requests · HERE Route Matching API

Repository structure

├── DOC_Model.py        # Main pipeline: API call, parsing, distance calc, export
├── requirements.txt
├── sample_input.txt    # Example GPS trace
├── dOCformat.pdf       # DOC format specification
└── Illustration.pdf    # Example output / illustration

Citation

@techreport{amsavalli2024pathlength,
  title       = {Estimation of Accurate Path Length with Geospatial Data Analysis},
  author      = {Amsavalli, Yogeswaran and Emvin, Carl},
  institution = {Chalmers University of Technology, Department of Mechanics and Maritime Sciences},
  address     = {Gothenburg, Sweden},
  year        = {2024},
  url         = {https://research.chalmers.se/publication/541772}
}

License

Released under the MIT License.

Author

Yogeswaran Amsavalli · GitHub

About

Master's thesis: builds Deterministic Operating Cycle (DOC) road models from GPS traces via the HERE API for vehicle energy & range estimation

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages