Convert raw LiDAR (.las / .laz) tiles into coloured, 3D-printable OBJ meshes using OSM data for classification.
- Python 3.10 (see options below)
- Git
- ~1 GB free disk space (dependencies + osmdata land polygons)
No local installation required. Runs JupyterLab in the browser using GitHub's cloud machines.
- Push this repo to GitHub (or fork it)
- Click Code → Codespaces → Create codespace on main
- Wait ~2 min for the container to build
- JupyterLab opens automatically in a browser tab
Free tier: 60 hours/month on a 2-core machine. Upgrade for more cores/RAM.
LAS files: upload them via the Codespaces file explorer or use the terminal to download them. They are not committed to the repo.
No Python installation required. Build time is ~2 min (pre-built wheels, no compilation).
- Install Docker: follow the official guide
- Clone this repo and
cdinto it - Run:
# Build image (~2 min — uses pre-built manylinux wheels, no apt compilation)
docker compose build
# Start JupyterLab in the background
docker compose up -d
# Open in browser
xdg-open http://localhost:8888 # Linux
open http://localhost:8888 # macOSLAS files are mounted read-only at /data/whangarei/ and /data/hope/ inside the container.
Edit the paths in docker-compose.yml to point at your own data directories.
Output files (output/) are written directly to the project folder on the host — no copy step needed.
To stop: docker compose down
Conda manages both Python and binary system libraries (GDAL, PROJ, GEOS) in one step, which avoids most platform-specific build issues.
Linux / WSL:
curl -L https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh -o miniforge.sh
bash miniforge.sh -b -p "$HOME/miniforge3"
eval "$($HOME/miniforge3/bin/conda shell.bash hook)"macOS (Apple Silicon):
curl -L https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-arm64.sh -o miniforge.sh
bash miniforge.sh -b -p "$HOME/miniforge3"
eval "$($HOME/miniforge3/bin/conda shell.bash hook)"conda create -n las2obj python=3.10 -y
conda activate las2objpip install -r requirements.txtpython -m ipykernel install --user --name las2obj --display-name "Python 3.10 (las2obj)"jupyter labOpen the URL printed in the terminal. Select the Python 3.10 (las2obj) kernel when prompted.
Use this if you already have Python 3.10 installed and prefer not to use Conda.
python3 --version # must show 3.10.xIf not, install it:
Ubuntu / Debian:
sudo add-apt-repository ppa:deadsnakes/ppa -y
sudo apt update
sudo apt install python3.10 python3.10-venv python3.10-dev -ymacOS:
brew install python@3.10Windows: download the installer from python.org/downloads
# Linux / macOS
python3.10 -m venv .venv
# Windows
py -3.10 -m venv .venv# Linux / macOS
source .venv/bin/activate
# Windows (PowerShell)
.venv\Scripts\Activate.ps1
# Windows (cmd)
.venv\Scripts\activate.batYou should see (.venv) prepended to your prompt.
pip install --upgrade pip
pip install -r requirements.txtNote (Linux): if
rasterioorpyprojfail to build, install system libraries first:sudo apt install libgdal-dev libgeos-dev libproj-devthen re-run
pip install -r requirements.txt.
python -m ipykernel install --user --name las2obj --display-name "Python 3.10 (las2obj)"jupyter labSelect the Python 3.10 (las2obj) kernel when prompted.
- Open
las2obj.ipynb - Edit the Config cell at the top:
LAS_FILE— path to your.lasor.lazfileLAND_FILE— path to the osmdata land-polygon zip (optional; auto-downloaded ifNone)RESOLUTION— grid cell size in metres (default1.0)
- Run all cells top-to-bottom (Kernel → Restart & Run All)
- Outputs are written to
output/
| File | Description |
|---|---|
output/<stem>.obj |
3D mesh with embedded vertex colours |
output/cell*.png |
Visualisation snapshots from each cell |
cache/ |
OSM and ocean mask caches (delete to force re-fetch) |
| Host path | Container path |
|---|---|
~/Downloads/whangarei/ |
/data/whangarei/ |
~/Downloads/hope/ |
/data/hope/ |
| Project folder | /notebook/ |
| Cell | Description |
|---|---|
| Config | File paths, resolution, tuning variables |
| 1 | Load LiDAR — density, classification map, RGB colour |
| 2 | Remove vegetation (ASPRS classes 3–5), re-visualise |
| 3 | Download OSM land polygons, derive ocean mask |
| 4 | Ocean classification (intensity + LiDAR class-9 + RGB) |
| 5 | Download OSM buildings, roads, waterways, greenspaces |
| 6 | Building raster (LiDAR class-6 + OSM footprints + border) |
| 7 | Full classification raster (building > road > green > water > ocean > ground) |
| 8 | Heightfield (95th pct buildings, 10th pct water, 50th pct terrain) |
| 9 | Export self-contained OBJ with embedded vertex colours |
| Variable | Cell | Default | Effect |
|---|---|---|---|
RESOLUTION |
Config | 1.0 |
Grid cell size in metres |
BUILDING_BORDER_M |
6 | 5 |
Border buffer around all buildings (m) |
ROAD_BUFFER_M |
7 | 6.0 |
Road linestring buffer radius (m) |
MIN_WATER_CELLS |
7 | 200 |
Min inland water patch size before → road |
MIN_GREEN_CELLS |
7 | 200 |
Min green space patch size before → road |
MIN_GROUND_CELLS |
7 | 200 |
Min ground patch size before → road |
MIN_ROAD_CELLS |
7 | 200 |
Min road patch size before → building |
OCEAN_INTENSITY_PCT |
4 | 20 |
Intensity percentile threshold for water signal |
BUILDING_OPEN_SIZE |
8 | 7 |
Opening kernel — strips antenna/cable spikes |
BUILDING_CLOSE_SIZE |
8 | 15 |
Closing kernel — fills dome/roof voids |
BUILDING_SMOOTH_SIZE |
8 | 9 |
Median kernel — final roof smoothing |
TARGET_XY_MM |
9 | 200.0 |
Longest print dimension (mm) |
BASE_MM |
9 | 4.0 |
Base plate thickness (mm) |
BUILDING_PAD_PX |
9 | 1 |
Extra colour dilation on building walls |