Skip to main content

Simple OSRM routing and Folium map drawing toolkit

Project description

cartons

A small Python toolkit for routing and map visualization.

cartons calculates routes using OSRM (via routingpy) and draws them on an interactive Leaflet map using folium.

With just a few lines of code you can compute a route between two coordinates and render it as an HTML map.

It is designed to be simple, lightweight, and easy to integrate into scripts or small projects.


Installation

Installation from PyPI availiable since 11.03.2026 Install from PyPI:

pip install cartons

Or install locally from the repository:

pip install -e .

Dependencies:

  • routingpy
  • folium

Quick Example

import cartons

m = cartons.draw(
    "https://router.project-osrm.org",
    8.5417, 47.3769,
    8.55, 47.38
)

m.save("route.html")

This generates an interactive HTML map showing the calculated route.


How It Works

The package has two main modules:

cartons/
├ routing.py
├ display.py
└ __init__.py

routing.py

Handles communication with the OSRM routing engine using routingpy.

It sends coordinates to the routing server and returns the full route response.

display.py

Extracts route geometry and draws the route using folium.

Coordinates returned by OSRM are converted from:

[lon, lat]

to

[lat, lon]

because Folium expects latitude first.


Public OSRM Server

The examples use the public demo server:

https://router.project-osrm.org

This server is suitable for testing and small scripts.

For production usage, running your own OSRM server is recommended.


Project Goals

cartons aims to provide:

  • simple routing interface
  • quick map visualization
  • minimal dependencies
  • easy integration into Python scripts

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cartons-1.0.1.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cartons-1.0.1-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file cartons-1.0.1.tar.gz.

File metadata

  • Download URL: cartons-1.0.1.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cartons-1.0.1.tar.gz
Algorithm Hash digest
SHA256 fe5d961a021c513ca69f2d99ca0582d5ab20c3035a59b5f6a8e5ee07f6cfb785
MD5 e789ab9f0ad007ac6dd48e7657a69f0f
BLAKE2b-256 a397ac17d926464873a8d36fda77b27e96c166555a82c66fbd16c0fccec95201

See more details on using hashes here.

Provenance

The following attestation bundles were made for cartons-1.0.1.tar.gz:

Publisher: python-publish.yml on AndPan3/cartons

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cartons-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: cartons-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cartons-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c9132599ab90dbb9004517496f431b04439adec92fda12d1d50842eee1655e41
MD5 67b5cea9ff2d94a763653f4560587025
BLAKE2b-256 f7e27d2f98ac86c7c40a40dd6f4693fa6afd78da3c24e9e1c8e2204f0cdc5187

See more details on using hashes here.

Provenance

The following attestation bundles were made for cartons-1.0.1-py3-none-any.whl:

Publisher: python-publish.yml on AndPan3/cartons

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page