🎨 VoxCity 3D Visualization¢

Visualize your 3D voxel city models using multiple methods.

Visualization OptionsΒΆ

Method

Description

Best For

Static (PyVista)

Multi-view rendered images

Documentation, reports

Interactive (Plotly)

In-notebook 3D exploration

Data exploration

OBJ Export

Open in external software

Blender, Rhino, SketchUp

VOX Export

MagicaVoxel format

Voxel art, rendering

PrerequisitesΒΆ

pip install voxcity plotly pyvista
# %pip install voxcity plotly

from voxcity.generator import get_voxcity
from voxcity.exporter.obj import export_obj
from voxcity.visualizer import visualize_voxcity, visualize_voxcity_plotly

meshsize = 5
rectangle_vertices = [
    (139.760, 35.680),
    (139.760, 35.690),
    (139.770, 35.690),
    (139.770, 35.680)
]

city = get_voxcity(
    rectangle_vertices,
    meshsize=meshsize,
    building_source='OpenStreetMap',
    land_cover_source='OpenStreetMap',
    canopy_height_source='High Resolution 1m Global Canopy Height Maps',
    dem_source='DeltaDTM',
    output_dir='output/viz_demo'
)

city.voxels.classes.shape

πŸ“¦ OBJ ExportΒΆ

Export the voxel city to Wavefront OBJ format for use in external 3D software.

Supported software: Blender, Rhino, SketchUp, 3ds Max, Maya, Cinema 4D

export_obj(city, output_dir='output/viz_demo', file_name='voxcity')
print('OBJ exported to output/viz_demo')

πŸ–ΌοΈ Static & Interactive VisualizationΒΆ

Static (PyVista)ΒΆ

Renders multi-view images with orthographic or perspective projection.

Interactive (Plotly)ΒΆ

3D scatter plot with orbit controls for exploration in Jupyter notebooks.

# Multi-view static rendering (PyVista)
visualize_voxcity(
    city,
    mode="static",
    projection_type="perspective",
    distance_factor=1.2,
    output_directory="output/viz_demo"
)

# Plotly interactive figure
fig = visualize_voxcity(city, mode="interactive", show=False, return_fig=True)
fig.show()

🎨 Color Mapping¢

VoxCity uses consistent colors for different element types:

Type

Color

Code

Building

Gray

[128, 128, 128]

Tree

Green

[34, 139, 34]

Ground

Brown

[139, 90, 43]

Water

Blue

[0, 0, 255]

Next StepsΒΆ

  • demo_obj.ipynb - Advanced OBJ export options

  • demo_envi-met.ipynb - Export for CFD simulations