2D Map to 3D Terrain Converter
Convert any 2D map image into interactive 3D terrain using WebGL. Upload heightmaps, adjust exaggeration, lighting, and export OBJ models.
About
Topographic maps encode elevation as color intensity. Misreading contour intervals or misjudging vertical scale leads to flawed site assessments, incorrect drainage planning, and costly engineering errors. This tool extracts a heightmap from any 2D image by computing per-pixel luminance L = 0.299R + 0.587G + 0.114B, then constructs a triangulated mesh rendered in real-time via WebGL with Phong shading. Vertical exaggeration E is user-adjustable from 0.1× to 5.0×. The tool assumes brighter pixels represent higher elevation. Grayscale heightmaps (DEM exports, NASA SRTM tiles) yield the most accurate results. Color photographs or satellite imagery will produce approximate terrain based on overall brightness, not true elevation data.
Formulas
Luminance (grayscale height) is extracted from each pixel using the ITU-R BT.601 weighted sum:
where R, G, B are the red, green, and blue channel values in the range [0, 255]. The vertex height is then:
where E is the vertical exaggeration factor. Per-vertex normals for Phong shading are computed via central finite differences on the heightmap grid:
The perspective projection matrix uses field-of-view θ = 45°, near plane zn = 0.1, and far plane zf = 100. Camera orbits using spherical-to-Cartesian conversion: x = r ⋅ sin(φ) ⋅ cos(θ), y = r ⋅ cos(φ), z = r ⋅ sin(φ) ⋅ sin(θ).
Reference Data
| Heightmap Source | Resolution | Coverage | Vertical Accuracy | Format |
|---|---|---|---|---|
| NASA SRTM | 30m | Global (60°N - 56°S) | ±16m | GeoTIFF / HGT |
| ASTER GDEM v3 | 30m | Global (83°N - 83°S) | ±8.68m | GeoTIFF |
| ALOS World 3D | 30m | Global | ±5m | GeoTIFF |
| USGS NED | 10m | USA | ±1.55m | GeoTIFF / IMG |
| EU-DEM v1.1 | 25m | Europe (EEA39) | ±2.9m | GeoTIFF |
| LiDAR (Airborne) | 0.5 - 2m | Regional | ±0.15m | LAS / LAZ |
| Mapbox Terrain RGB | 5m (zoom 15) | Global | ±10m | PNG (RGB-encoded) |
| Copernicus DEM | 30m | Global | ±4m | GeoTIFF |
| ETOPO1 | 1.8km | Global (incl. ocean) | ±10m | NetCDF / GeoTIFF |
| GEBCO 2023 | 450m | Global ocean bathymetry | ±100m | NetCDF |
| TanDEM-X DEM | 12m | Global | ±2m | GeoTIFF |
| JAXA DSM | 5m | Japan | ±5m | GeoTIFF |
| Swiss ALTI3D | 2m | Switzerland | ±0.5m | GeoTIFF / XYZ |
| OpenTopography LiDAR | 1m | Various regions | ±0.1m | LAS / Raster |