{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 🎨 VoxCity 3D Visualization\n", "\n", "Visualize your 3D voxel city models using multiple methods.\n", "\n", "## Visualization Options\n", "\n", "| Method | Description | Best For |\n", "|--------|-------------|----------|\n", "| **Static (PyVista)** | Multi-view rendered images | Documentation, reports |\n", "| **Interactive (Plotly)** | In-notebook 3D exploration | Data exploration |\n", "| **OBJ Export** | Open in external software | Blender, Rhino, SketchUp |\n", "| **VOX Export** | MagicaVoxel format | Voxel art, rendering |\n", "\n", "## Prerequisites\n", "\n", "```python\n", "pip install voxcity plotly pyvista\n", "```" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# %pip install voxcity plotly\n", "\n", "from voxcity.generator import get_voxcity\n", "from voxcity.exporter.obj import export_obj\n", "from voxcity.visualizer import visualize_voxcity, visualize_voxcity_plotly\n", "\n", "meshsize = 5\n", "rectangle_vertices = [\n", " (139.760, 35.680),\n", " (139.760, 35.690),\n", " (139.770, 35.690),\n", " (139.770, 35.680)\n", "]\n", "\n", "city = get_voxcity(\n", " rectangle_vertices,\n", " meshsize=meshsize,\n", " building_source='OpenStreetMap',\n", " land_cover_source='OpenStreetMap',\n", " canopy_height_source='High Resolution 1m Global Canopy Height Maps',\n", " dem_source='DeltaDTM',\n", " output_dir='output/viz_demo'\n", ")\n", "\n", "city.voxels.classes.shape\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "---\n", "## 📦 OBJ Export\n", "\n", "Export the voxel city to Wavefront OBJ format for use in external 3D software.\n", "\n", "**Supported software:** Blender, Rhino, SketchUp, 3ds Max, Maya, Cinema 4D" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "export_obj(city, output_dir='output/viz_demo', file_name='voxcity')\n", "print('OBJ exported to output/viz_demo')\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "---\n", "## 🖼️ Static & Interactive Visualization\n", "\n", "### Static (PyVista)\n", "Renders multi-view images with orthographic or perspective projection.\n", "\n", "### Interactive (Plotly)\n", "3D scatter plot with orbit controls for exploration in Jupyter notebooks." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Multi-view static rendering (PyVista)\n", "visualize_voxcity(\n", " city,\n", " mode=\"static\",\n", " projection_type=\"perspective\",\n", " distance_factor=1.2,\n", " output_directory=\"output/viz_demo\"\n", ")\n", "\n", "# Plotly interactive figure\n", "fig = visualize_voxcity(city, mode=\"interactive\", show=False, return_fig=True)\n", "fig.show()\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "---\n", "## 🎨 Color Mapping\n", "\n", "VoxCity uses consistent colors for different element types:\n", "\n", "| Type | Color | Code |\n", "|------|-------|------|\n", "| Building | Gray | `[128, 128, 128]` |\n", "| Tree | Green | `[34, 139, 34]` |\n", "| Ground | Brown | `[139, 90, 43]` |\n", "| Water | Blue | `[0, 0, 255]` |\n", "\n", "## Next Steps\n", "\n", "- `demo_obj.ipynb` - Advanced OBJ export options\n", "- `demo_envi-met.ipynb` - Export for CFD simulations" ] } ], "metadata": { "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 2 }