How to Render 3D Maps and Terrain from Python Without the Pain of Heavy C++
The last time I needed to render a high-quality 3D terrain model from a height matrix in Python, I hit the usual wall. Either use Matplotlib with its slow 3D graphics, or drag in heavy GIS packages, deal with C++ wrappers, and manually configure the graphics context.
The forge3d project tries to close this gap. The author took a Rust engine, wrapped it in the WebGPU graphics API via the wgpu library, and built ready-made wheels for Python. The result is a tool that opens an interactive viewer or renders scenes without a window in just a few lines of code.
What forge3d can do under the hood
The library's main idea is to combine familiar data science and GIS data types with fast GPU rendering. You don't need to write shaders or understand WebGPU pipelines, even though that's what's running underneath.
Here's what the library delivers out of the box:
- Loads height matrices from GeoTIFF and NumPy arrays.
- Reads point clouds in LAZ, COPC, and EPT formats.
- Works with raster and vector overlay layers.
- Supports the COG protocol for streaming tiles from the network.
- Embeds directly into Jupyter Notebook via a dedicated widget.
Installation is straightforward:
pip install forge3d
If you plan to run 3D directly in notebooks or pull in test datasets, you can install the extended package set right away:
pip install "forge3d[all]"
Rendering terrain in five lines of code
Let's see what working with the viewer looks like. The code below downloads a test DEM file of Mount Rainier, opens a window, and saves a high-resolution frame.
import forge3d as f3d
dem_path = f3d.fetch_dem("rainier")
with f3d.open_viewer_async(terrain_path=dem_path, width=1440, height=900) as viewer:
viewer.set_z_scale(0.1)
viewer.set_orbit_camera(phi_deg=28, theta_deg=49, radius=5400, fov_deg=42)
viewer.set_sun(azimuth_deg=302, elevation_deg=24)
viewer.snapshot("rainier.png", width=1920, height=1080)
Note the syntax. Sun position, camera angle, and Z-axis scaling are set via intuitive methods. At the same time, you can render the scene entirely without a graphics environment, say, in CI/CD or batch map processing scripts.
Why WebGPU and Rust
The technology choice is architecturally justified. Rust delivers high speed and safety when processing binary formats like LAZ or heavy GeoTIFF files. WebGPU serves as a modern cross-platform API that runs equally well on Vulkan, Metal, or DirectX 12.
You get compiled binaries in a single Wheel package. No manual builds of C++ libraries or conflicting OpenGL system drivers.
What's open, and what you'll pay for
The developer has set up a clear model. Core functionality is released under Apache 2.0 and MIT licenses. You can build surfaces, load point clouds, overlay vectors, and assemble animations.
For cartographic modules like MapPlate, export to SVG/PDF, scale bars, and loading 3D buildings from GeoJSON or CityJSON, the author asks for a commercial key. It activates via the f3d.set_license_key(...) method.
Who this tool is for
If your work involves geodata analysis, terrain visualization, or map creation in Python, this project is definitely worth bookmarking. The library has around 560 stars on GitHub, but the code looks clean and the documentation has plenty of working examples.
For simple 2D maps, stick with Folium or GeoPandas. But if you need fast 3D terrain or point cloud processing without diving into low-level graphics, forge3d will handle the job without extra hassle.
Related projects