Simple OSRM routing and Folium map drawing toolkit
Project description
cartons
A lightweight Python toolkit for routing and map visualization.
cartons calculates routes using OSRM (Open Source Routing Machine) and renders them on interactive maps using Folium. With only a few lines of Python, you can compute a route between two coordinates and generate an HTML map displaying the route.
Features
- Simple routing between geographic coordinates
- Interactive map visualization
- Lightweight and easy to integrate into scripts
- Minimal code required
- Built on top of OSRM and Folium
Installation
Install via pip:
pip install cartons
Quick Example
import cartons
#if you want to see the map for fun, open it using the Webbrowser module
import webbrowser
# Bern → Zürich
m = cartons.draw(
"https://router.project-osrm.org",
7.4442153, 46.94686,
8.5431302, 47.3668725,
"red",5,"OpenStreetMap","car"
)
filename = "route.html"
m.save(filename)
webbrowser.open(filename)
This generates an interactive HTML map showing the route.
How It Works
cartons connects to an OSRM routing server to calculate routes and renders them using Folium.
Coordinates
↓
cartons routing
↓
OSRM route calculation
↓
route geometry
↓
Folium map rendering
↓
Interactive HTML map
API
draw()
Creates a route and returns a Folium map.
draw(base_url, lon1, lat1, lon2, lat2, color="blue", weight=5,tiles="OpenStreetMap",transport="car")
| Parameter | Description |
|---|---|
| base_url | OSRM routing server URL |
| lon1 | Longitude of starting point |
| lat1 | Latitude of starting point |
| lon2 | Longitude of destination |
| lat2 | Latitude of destination |
| color | Route line color |
| weight | Route line thickness |
| tiles | Map tiles |
| transport | transportation mode for route generation |
Returns:
folium.Map
You can then save or modify the map using Folium.
Example:
map = cartons.draw(...)
map.save("route.html")
Example Output
The generated map is fully interactive.
Features include:
- Zoom and pan
- Inspect the route visually
- Export as an HTML file
- Embed into web pages
Use Cases
cartons can be useful for:
- route visualization
- travel route maps
- logistics planning
- GPS data analysis
- small mapping tools
- data science experiments
Development
Clone the repository:
git clone https://github.com/AndPan3/cartons.git
cd cartons
Install in development mode:
pip install -e .
Contributing
Contributions are welcome.
If you find a bug or have ideas for improvements:
- Open an issue
- Submit a pull request
License
MIT License
Author
AndPan3
Acknowledgements
This project uses:
- OSRM for routing
- Folium for map visualization
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cartons-1.1.3.tar.gz.
File metadata
- Download URL: cartons-1.1.3.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3132b206f9dd6faa1738eb425e3274efd20e555d55b19a96a2c33b7ebde27b46
|
|
| MD5 |
1a54e7919a39c7b0eee2759b1e5990d3
|
|
| BLAKE2b-256 |
f4bfb033755fd0750289be4f39cda5b0945036635bc31907763738ed4e3a1619
|
Provenance
The following attestation bundles were made for cartons-1.1.3.tar.gz:
Publisher:
python-publish.yml on AndPan3/cartons
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cartons-1.1.3.tar.gz -
Subject digest:
3132b206f9dd6faa1738eb425e3274efd20e555d55b19a96a2c33b7ebde27b46 - Sigstore transparency entry: 1101898342
- Sigstore integration time:
-
Permalink:
AndPan3/cartons@d3af4efc47076fdaed05791e4da273f4f895dcea -
Branch / Tag:
refs/tags/1.1.3 - Owner: https://github.com/AndPan3
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@d3af4efc47076fdaed05791e4da273f4f895dcea -
Trigger Event:
release
-
Statement type:
File details
Details for the file cartons-1.1.3-py3-none-any.whl.
File metadata
- Download URL: cartons-1.1.3-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e64d3177e29a83e95314d5a44f179159bf3bec3c0e5da67efec94e5a2df45b0d
|
|
| MD5 |
73bebadda847ad82265cc8c10f6dffa8
|
|
| BLAKE2b-256 |
442c1d9543958f30ba41a86ecd9c8114551dc4db8b28216c34b622ae1f6849a9
|
Provenance
The following attestation bundles were made for cartons-1.1.3-py3-none-any.whl:
Publisher:
python-publish.yml on AndPan3/cartons
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cartons-1.1.3-py3-none-any.whl -
Subject digest:
e64d3177e29a83e95314d5a44f179159bf3bec3c0e5da67efec94e5a2df45b0d - Sigstore transparency entry: 1101898396
- Sigstore integration time:
-
Permalink:
AndPan3/cartons@d3af4efc47076fdaed05791e4da273f4f895dcea -
Branch / Tag:
refs/tags/1.1.3 - Owner: https://github.com/AndPan3
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@d3af4efc47076fdaed05791e4da273f4f895dcea -
Trigger Event:
release
-
Statement type: