RepositoryC++
IB

ibaaj/dijkstra-cartography

Using Dijkstra's algorithm ("finding the shortest paths between nodes in a graph") to draw maps :earth_africa:.

1.2kstars
81forks
0issues
1views

Featured achievements

The project's latest awards

1
TINIX TRENDING·Topic: paris

#1 Repository of the month

1
TINIX TRENDING·Topic: algorithm

#1 Repository of the month

1
TINIX TRENDING·Topic: cartography

#1 Repository of the month

Dijkstra Cartography

Introduction

I was fascinated by the project "Roads to Rome" by Moovellab but sad that it isn't opensource. Helped by this project (thanks @tristramg ) I started to build my own map.

I did not have any GIS background but it was very interesting to discover what we can do with. The code isn't very good (I'm not a C++ guru).

The project is named "Dijkstra Cartography" but sometimes BFS algorithm is better (if all the edges have the same weight).

This code can be useful for cartographer, as I found a lot of errors for the river Amazon (see here) or.. to have your own poster 😉.

Extract

You may not want to use the planet.osm file (644GB - all the openstreetmap data in one file). Choose the right file here and extract what you really need with openstreetmap's tools : osmconvert, osmfilter, osmosis, osmium...

One interesting way is that you can extract all the data within a polygon with osmconvert, and here are some cities polygons.

Routing

MapRouting system used
ParisGraphhopper - "Dijkstrabi"
AmazonDijkstra's algorithm
RailwayOSRM
FlightsDijkstra's algorithm

The first thing to do is to gather the statistics of usage of all paths : for each location, execute the routing algorithm you chose to your root location (your home for example). Merge all and sort the data by the most used path.

Projections

MapProjection
ParisLambert 93-I EPSG:27571
AmazonESRI:102032 (South America Equidistant Conic)
RailwayMercator
FlightsWSG84

You can follow this guide, search SpatialReference or ESPG.io.

Drawing

Considering the data is sorted and well projected.

The width and height of the image are defined like this :

width = (maxX-minX)/scale;
height = (maxY-minY)/scale;

To draw these paths, I used this function (plotted using R) : ./results/function.jpg

as it gives me a percent (between [0;1] here) of how the line width must be important. Also I can accentuate the decreasing by modifying parameters inside exp().

I used cairo and I was really suprised that I can understand these map without using any shapefile.

Details for each map

Bonus

./results/paris.gif

License

See here.

Similar Projects

Discover other similar projects and AI models.

RepositoryC++
valhalla/valhalla

Open Source Routing Engine for OpenStreetMap

6.5k
Dec 1, 2026
RepositoryPython
marceloprates/prettymaps

Draw pretty maps from OpenStreetMap data! Built with osmnx +matplotlib + shapely

14.4k
Jul 30, 2026
RepositoryJava
graphhopper/graphhopper

Open source routing engine for OpenStreetMap. Use it as Java library or standalone web server.

6.8k
Dec 1, 2026
RepositoryJavaScript
umap-project/umap

uMap lets you create maps with OpenStreetMap layers in a minute and embed them in your site.

1.6k
Nov 24, 2026
Repository
jwasham/coding-interview-university

A complete computer science study plan to become a software engineer.

365.2k
Nov 7, 2026
RepositoryPython
TheAlgorithms/Python

All Algorithms implemented in Python

226.6k
Nov 13, 2026
RepositoryJavaScript
trekhleb/javascript-algorithms

📝 Algorithms and data structures implemented in JavaScript with explanations and links to further readings

196.8k
Jul 26, 2026
RepositoryJavaScript
CyC2018/CS-Notes

:books: 技术面试必备基础知识、Leetcode、计算机操作系统、计算机网络、系统设计

186.6k
Nov 27, 2026
RepositoryTypeScript
yangshun/tech-interview-handbook

Curated coding interview preparation materials for busy software engineers

143.8k
Aug 7, 2026