[002-003] How to Create Terrain and Align 3D Buildings in Esri CityEngine
Set up a 3D terrain from grayscale heightmaps and align GIS building footprints using CGA rules in CityEngine.
In this tutorial, you will learn the fundamental process of setting up a CityEngine environment, generating 3D terrain from heightmaps, and aligning GIS building footprints. This is the most essential workflow for building realistic Digital Twins.
📌What You'll Learn
- How to set up a CityEngine workspace and organize GIS assets
- Importing and configuring Heightmaps (TIF) and Textures correctly
- Aligning 2D SHP footprints to 3D terrain elevation
- Basic CGA (Computer Generated Architecture) extrusion logic
Esri CityEngine is a powerhouse for urban planning and Digital Twin creation. Whether you are visualizing a smart city or conducting a massive scale environmental analysis, mastering CGA rules and terrain alignment is essential. In this guide, we will explore the core philosophy of CityEngine and walk through the practical process of generating 3D environments from GIS data and heightmaps.
Understanding the Esri CityEngine Terrain Workflow
This is the second installment of our series. If you are just starting, you may want to check [001] Create 3D Buildings from SHP File (Extrude + CGA Guide) to understand how data properties drive 3D geometry.
This tutorial is not a generic "step-by-step" for absolute beginners. Instead, it is designed for those who have installed CityEngine, felt the initial excitement from the official gallery images, and perhaps felt overwhelmed by the CGA programming requirement. To truly master CityEngine, you need a mix of interest in both 3D modeling and programming.
What is CGA in Esri CityEngine?
CGA stands for Computer Generated Architecture. It is a specialized programming language designed to define the shapes and forms of buildings. Unlike traditional 3D software (like 3ds Max or Blender) where you manually move vertices, CityEngine is "hard-coding" software. You write rules, and the software generates the city.
For official documentation, refer to the CityEngine Help and the CGA Reference. Since these resources are in English, using a translation tool like DeepL can be incredibly helpful for non-native speakers.
Practical Note: The Learning Curve
To fully utilize CityEngine, you should eventually familiarize yourself with GIS, 3D principles, CGA and Python. Python integration allows for advanced automation, though mastering CGA alone will take you very far in urban procedural modeling.
How to Import Heightmaps into Esri CityEngine
Why Heightmaps Are Important
CityEngine does not generate terrain directly from raw numerical maps. Instead, it uses a heightmap (a grayscale image) created in a GIS program to define elevation. For accurate placement, your image must have a coordinate system file (.prj).
Preparing Terrain Files and GIS Data
Download the exercise file MapLayer.zip (Verified and safe file for CityEngine.)
I recommend using geoTiff (.tif) files over standard PNG or JPG for heightmaps to preserve precision. For this tutorial, we use a set of files including building footprints (SHP), a satellite image (JPG), and a terrain heightmap (TIF).
After creating a new project and scene in CityEngine, copy your data into the respective project folders (data, images, maps).
Creating a Terrain Map Layer
There are two ways to add a Map Layer: right-clicking the file in the Navigator and selecting "Import," or using the top menu: Layer > New Map Layer....
Choose Terrain from the wizard and click Next. Browse for your heightmap file.
Setting Coordinate Systems Correctly
Always ensure your Scene Coordinate System matches your data. When prompted, select the appropriate PRJ file (e.g., Korea 2000 Central Belt). If the coordinates are mismatched, your buildings will not sit correctly on the terrain.
Applying Satellite Texture to Terrain
Next, add a Texture File by browsing for your satellite imagery to drape it over the 3D terrain.
How to Align SHP Building Footprints to Terrain
Importing Building Shapefiles
Now, import your building footprints (building2.shp). Since the SHP file only contains 2D coordinates, the shapes will initially appear at the base level (zero elevation).
Using Align Shapes to Terrain in CityEngine
To move the footprints to their correct elevation, go to Shape > Align Shapes to Terrain.... In the Align Function, select Translate to Average and choose your terrain layer as the source.
How to Create 3D Buildings with CGA Rules
Finally, we turn these flat polygons into 3D structures using a rule file. In the Inspector panel, click Assign... under the Rule File section and select a CGA file.
Writing a Basic Extrude Rule
Please type the following code and save it as "**01_extrude.cga**":
attr BD_Floor = 0
Lot --> extrude(y, BD_Floor * 3)
Understanding attr Parameters
Variables declared with attr can be adjusted dynamically in the Inspector window.
To link the building height to the data in your SHP file, click Connect Attribute next to your height parameter (e.g., BD_Floor). Select the SHP layer and the specific attribute (e.g., NMLY) that represents the number of floors.
Generating Procedural Buildings from GIS Data
Click Generate (or press Ctrl+G), and CityEngine will procedurally extrude the buildings based on the data and the terrain height.
Translate to Average vs Translate to Minimum
When working with very steep slopes, the "Translate to Minimum" function is usually best to keep building foundations somewhat level. If you use "Project All," the footprint might distort to follow the terrain perfectly, which isn't realistic for architecture.
Summary and Next Steps
We have successfully created a 3D environment by combining GIS shapefiles, heightmaps, and procedural rules. This foundation allows you to perform advanced urban analysis. In our next lecture, we will dive deeper into color-coding these buildings based on their usage.
FAQ
What is the best heightmap format for Esri CityEngine?
GeoTIFF (.tif) is generally the best option for CityEngine terrain workflows because it preserves elevation precision and supports coordinate system information through PRJ files.
Why is the PRJ file important in CityEngine?
The PRJ file defines the coordinate reference system used by GIS data. Without matching coordinate systems, terrain layers and building footprints may appear in incorrect locations or elevations.
- Learn previous workflow in [001] Create 3D Buildings from SHP File (Extrude + CGA Guide)
- Continue learning with [004] How to Color Building by Attribute in Esri CityEngine
Comments
Post a Comment
Feel free to leave a comment if you have any questions about Global Mapper or CityEngine. I will get back to you with a sincere response as soon as possible. (Please note that all comments are moderated and manually approved to maintain a high-quality community. Promotional or spam content will not be published.)