Turn flat CAD floor-plan PDFs into georeferenced, 3D indoor maps.
Scrape → extract vectors → segment rooms → georeference → GeoJSON → 3D night-style layers.
Universities, hospitals, malls, and airports all sit on piles of CAD floor-plan PDFs — and no easy way to put them on a map. Commercial indoor-map vendors digitize plans by hand and charge per building; there is no open, automated path from "a PDF of a floor plan" to "an interactive 3D floor you can drop on a map."
pdf2floor is that path. Feed it a vector floor-plan PDF and the building's
footprint; it extracts the walls, segments the rooms, figures out where and how
the plan sits on the Earth, and emits GeoJSON that renders as a glowing,
roofless 3D "dollhouse" in any MapLibre or Mapbox-GL map — no proprietary SDK,
no per-building fee, no meshes or custom 3D code.
(George Eastman Hall, Floor 1 — the exact plan the bundled example builds
(examples/), rendered with fill-extrusion layers on a dark
map. Rooms in orange, stairs/elevators in blue, the tapped room in yellow.)
- ✅ Vector-PDF detection — refuses scans up front, so you know what you have.
- ✅ Wall + room-number + room-name extraction (PyMuPDF).
- ✅ Room segmentation through doorways via raster morphological closing + connected components; room identity from the room-number text.
- ✅ Enrichment — room categories, doorways, and dual-height 3D wall ribbons.
- ✅ Automatic georeferencing to an OSM footprint (label-anchored, wall-thickness scale prior, north-arrow pinning) — lands ~90% of buildings unattended.
- ✅ Human placement tool for the rest — drag/rotate/scale over satellite imagery, crash-safe per-building saves, verify against the real pipeline.
- ✅ GeoJSON output — renders in any Mapbox-GL / MapLibre-GL map (or geojson.io).
git clone https://github.com/kambar231/pdf2floor
cd pdf2floor
pip install -r requirements.txt # or: pip install -e .# Convert the bundled Eastman Hall floors to GeoJSON:
python examples/convert_example.py
# -> examples/output/eastman.geojson (both floors, tagged by `level`)The output is standard GeoJSON. To see the 3D result, drop
examples/output/eastman.geojson into any renderer:
- geojson.io or kepler.gl — instant, in-browser.
- Mapbox GL / MapLibre GL — add it as a source and style the
kind-tagged features asfill/line/fill-extrusionlayers (see docs/METHOD.md for the exact paint spec that produces the dollhouse look).
The image above is this data rendered as fill-extrusion layers on a dark
basemap.
import json
from shapely.geometry import shape
from pdf2floor import convert_floor, is_vector_pdf
assert is_vector_pdf("plan.pdf") # must be vector CAD, not a scan
footprint = shape(json.load(open("footprint.geojson"))["geometry"])
fc, meta = convert_floor("plan.pdf", footprint, level="01")
print(meta["rooms"], meta["doors"], meta["score"]) # 102 41 0.906
json.dump(fc, open("floor01.geojson", "w"))python -m pdf2floor plan.pdf footprint.geojson -o floor01.geojson --level 01| Stage | File | What happens |
|---|---|---|
| Acquire | tools/acquire/ |
scrape PDF links, download (auth if needed) |
| Extract | pdf2floor/extract.py |
PDF → wall segments + room text |
| Segment | pdf2floor/segment.py |
walls → room polygons (morphological closing) |
| Enrich | pdf2floor/enrich.py |
categories, doors, 3D wall ribbons |
| Georef | pdf2floor/georef.py |
fit plan onto its real footprint |
| Build | pdf2floor/features.py |
assemble tagged GeoJSON |
| Place | tools/place/ |
hand-align the hard ones |
| Render | any GL map | fill + fill-extrusion layers, kind-tagged |
Full technical write-up: docs/METHOD.md. Data acquisition guide: docs/ACQUISITION.md.
Floor plans contain wall lines, not room polygons, and doorways are gaps —
so naive polygonization leaks every room into the corridor. pdf2floor
rasterizes the walls, morphologically closes the image with a door-width
kernel (doorways seal, walls stay), and takes connected components of the
free space. Each blob is a room; the room-number text landing inside it gives
its identity. The raster only decides identity and shape — the crisp original
vectors do the rendering.
There is no custom 3D. The walls become thin polygons ("ribbons"), and the map
engine's built-in fill-extrusion layer — the same primitive that draws 3D
city buildings — pulls them up (taller for the exterior, lower for partitions).
A dark background layer, a night light preset, and an emissive glow do the rest.
The output is plain GeoJSON. The demo uses MapLibre GL (fully open-source,
no token). The identical style spec works in Mapbox GL — see METHOD.md for
the Mapbox Standard slot / lightPreset / show3dObjects niceties and the
emissive-strength gotcha (runtime layers render black under night lighting
without it).
- Vector PDFs only. Scans need an ML vectoriser first (out of scope).
- Georeferencing is inference, not magic — ~90% land automatically, the rest need the placement tool. Even a perfect OSM fit can disagree with a basemap's own 3D buildings by a couple of metres (different data source).
- Room segmentation depends on wall quality. Open-volume buildings with few interior walls, or plans with no room-number text, produce weaker results (still renderable, flagged by the QA gate).
- Batch driver + per-project config for whole campuses.
- OCR fallback for plans whose room numbers are outlined (no text layer).
- IMDF export alongside GeoJSON.
- Flutter rendering example (this began as a Flutter app).
Built while adding an indoor-map feature to a campus social app: pin a room, tap the building, walk its floors in 3D. The pipeline turned out to be generally useful and vendor-free, so it's open source.
Kambar Mangibayev — github.com/kambar231
MIT — see LICENSE. The bundled sample floor plan is included for demonstration; you are responsible for the rights to any plans you process.
- Ground truth for the algorithm is docs/METHOD.md; keep it in sync with code.
- The transform in
georef.fit_transform(itsmake_tx) and the placement tool'stoLatLng()intools/place/index.htmlmust stay identical — a parity test is the guard; break one and hand-placements silently corrupt. - Never commit credentials (
cookies*.txt,*_session.txtare gitignored).

