To access the tutorial projects in ArcGIS CityEngine, open CityEngine and click Help > Download Tutorials and Examples in the main menu. After choosing a tutorial or example, the project is automatically downloaded and added to your CityEngine workspace.
Usually, you create the terrain first when you start a CityEngine scene. Terrains can be created from simple image files or from digital elevation models (DEMs), such as a GeoTIFF file in which the georeferencing information is supported.
In this tutorial, you'll learn about creating and aligning terrains; growing streets and cleaning up streets, and the fundamentals of dynamic city layouts.
Create a terrain
To create a terrain, do the following:
- Expand the \Tutorial_02_Terrain_and_Dynamic_City_Layouts\ tutorial folder in the Navigator.
- Open the Part_1_Start.cej scene in the \scenes\ folder.
- Open the \maps\ folder, and drag the elevation.jpg image into the Viewport to open the Import dialog box.
- Select Terrain Import and click Next.
- Under Texture File, click Browse to select the topo.png texture file in the \maps\ folder.
- Click Open.
- Leave the Channel property set to brightness..
- Set the Maximum Height value to 150.
- Under Bounds, edit the Dimensions and Location values to look like the following image:
Note:
If you load an image without georeference information, its pixel resolution is set as the terrain dimensions.
- Select the Keep ratio button and ensure the alignment button is set to the center.
- Click Finish.
The Terrain elevation layer is created and added to the Scene Editor.
- Click the layer in the Scene Editor to edit the attributes in the Inspector.
- Change the Resolution values.
The resolution of the terrain determines the number of subdivisions of the plane for the terrain mesh.
You can play around with the resolution, which is set to the size of the heightmap image by default. By customizing the grid size, you can affect the scene performance.
Open the Part_1_End.cej scene to see the finished example located in the \scenes\ folder.
Note:
Currently, CityEngine only supports image-based terrains (gray scale height maps); it does not support 3D meshes. If you only have a 3D mesh, or any other data type, you need to convert it to a heightmap.
Grow streets
In Tutorial 1: Essential skills, you learned how to grow streets on a flat grid without elevation present. Now, you'll use the Grow Streets tool and algorithm to directly adapt the streets to the actual terrain elevation.
Grow streets with a heightmap
To grow streets with a heightmap, do the following
- Click the Part_2_Start.cej file to open the scene.
- Click Graph > Grow Streets... in the main menu to open the Grow Streets dialog box.
- Expand the Environment Settings section.
- Next to Heightmap, click the drop-down menu and select Terrain elevation.
- Click Apply.
The Streetnetwork layer is added to the Scene Editor.
The streets automatically align to the terrain.
- Click Close to view the streets in the Viewport.
Grow streets with obstacle maps
You may have noticed that the Grow Streets tool grows streets randomly. This includes areas in which you may not want streets. You can create an obstacle map to allow you to leave those areas empty and minimize the manual cleanup process. An obstacle map is a black and white image in which the brightness defines the areas that streets can grow.
To add an obstacle map, do the following:
- Right-click in the Scene Editor and select New > New Map Layer to open the New Map Layer dialog box.
- Click Obstacle.
- Click Next.
- Click Browse and select the obstacles.png file in the \maps\ folder.
- Keep the Channel property set to brightness.
- Set the Obstacle Threshold value to 0.5.
The Obstacle Threshold defines the image brightness that distinguishes between obstacles and non-obstacles.
- Under Bounds, set the values to your terrain’s extent.
- Click Finish.
The New Obstacle map layer is created in the Scene Editor.
- Expand the Layer Attributes section in the Inspector:
attr obstacle = brightness < 0.5
The code determines the attribute mapping, in this case as a Boolean value (true/false).
- To apply the obstacle map when growing streets, first turn off the visibility box of the New Obstacle layer in the Scene Editor.
- Click in the Viewport to deselect the New Obstacle layer in the Scene Editor.
- Click Graph > Grow Streets... in the main menu again.
- Expand the Environment Settings section.
- Next to Obstaclemap, click the drop-down menu and select New Obstacle to assign the obstacle map.
- Click Apply.
The Grow Streets tool creates streets in the white areas of the obstacle map and doesn't in the black areas.
Your scene should look something like the Part_2_End.cej scene.
Note:
The Grow Streets tool also allows you to automatically create street patterns using the parameters. See Street pattern examples for more information.
Clean up streets
Sometimes the street networks have conflicting graph segments that need to be cleaned up. These errors are highlighted in red when proper shapes can't be created. Use the Cleanup Graph tool to clean up street network issues.
- Open the Part_3_Start.cej scene.
- Zoom to a conflicting graph segment marked in red.
- Select the area around the conflicting segment with the Select tool .
- Click the Cleanup Graph tool (C) on the toolbar or select Graph > Cleanup Graph... in the main menu to open the Cleanup Graph dialog box.
- Keep the default settings.
See Cleanup streets for more information.
- Click Finish.
Compare your scene to the Part_3_End.cej scene.
Align terrain
Streets that are created usually follow the surface of the terrain or the location of buildings. Often, created objects in a scene aren't aligned properly to the terrain, such as when importing 2D GIS data.
The following table lists the tools that can align streets and shapes with the terrain:
Align Graph to Terrain | Projects street segments onto the terrain. |
Align Shapes to Terrain | Projects static shapes onto the terrain*. |
Align Terrain to Shapes | Aligns the terrain to static and/or dynamic shapes. |
Note:
*Shapes that are manually drawn or imported are called static shapes. Regarding alignment, the dynamic city layout tools create dynamic shapes that cannot be aligned with the alignment tools. Since dynamic shapes are created as the children of (dynamic) blocks, (the same is true for streets), the Block Subdivision parameters contain a specific parameter for the alignment. See Block parameters for more information.
Align the graph to the terrain
First, you will align the graphs to the terrain.
- Open the Part_4_Start.cej scene.
- Select some shapes in the scene.
- Click the Align Graph to Terrain tool on the toolbar or select Graph > Align Graph to Terrain... in the main menu.
- Next to Heightmap, click the drop-down menu and select Terrain elevation.
See Align streets to terrain for more information.
- Set the Offset value to 0.2.
- Click Finish.
Note:
The change isn't very noticeable. For a stronger effect, change the Maximum Height value.
Align the terrain to shapes
Next, you will align the terrain to the dynamic shapes in your scene.
- Select some shapes in the scene again.
- Click the Align terrain to shapes tool on the toolbar or select Terrains > Align Terrain to Shapes... in the main menu to open the Align Terrain to Shapes dialog box.See Align terrain to shapes for more information.
- Keep the default settings and click Apply.
Note:
There is a very slight change since your streets were aligned to the terrain already.
- Click Close.
- Click the Terrain elevation layer in the Scene Editor.
- Under the Elevation section in the Inspector, alternate disabling and enabling the Apply Alignments setting with the drop-down menu.
The terrain switches back and forth between the unaligned and aligned state. This means that the alignment data, or the elevationDelta property, is stored as a file.
- Expand the Layer Attributes section to view how the elevationDelta property helps define the elevation attribute.
attr elevation = map_01(brightness, minHeight, maxHeight) + elevationDelta + elevationOffset
- Save your scene.
- Click File > Refresh Workspace to refresh the tutorial project workspace.
The \data\ folder now contains the elevation delta file in the \Part_4_Start.cej\ folder.
Ensure that you save the scene after aligning the terrain the first time.
- To view the elevation file from the top view, create a new viewport by clicking Window > New Viewport > Top View in the main menu.
- Drag the elevation_delta file into the Top View viewport.
The 16-bit delta map stores the elevation changes (gray = no change; black = lower; white = higher). See Elevation delta maps for more information.
Open the Part_4_End.cej scene to see the finished scene.
Dynamic city layouts
Dynamic city layouts is a set of tools and functionalities that allow you to quickly create city layouts. The result is a series of shapes, ready for use with CGA rules to create 3D models. The main elements are streets and blocks. Blocks are created if the street center lines physically enclose an area (and the network is cleanly connected). Blocks are represented with a dashed line, which you can select.
Both street segments and blocks have individual parameters that drive the creation of their children, the dynamic shapes.
Object types
When you explore the streets that you've grown, you'll find that there are three selectable object types whose parameters drive and influence the shape creation: segments, nodes, blocks.
Segment Parameters | |
Node Parameters | |
Block Parameters |
The Create Shape parameter is common to all three object types and enables or disables the shape geometry creation. For example, you may want to create shapes for the street, but not subdivisions in the blocks.
Feel free to play around with the parameters of the different object types, such as adjusting the width of streets and sidewalks; creating some roundabouts and editing their radii; or creating some cul-de-sacs.
Block subdivision types
You'll next work with block subdivisions. Select a block in the scene and change the Subdivision Type parameter. Each subdivision algorithm has its own parameters and creates a specific pattern.
Recursive Subdivision | |
Skeleton Subdivision | |
Offset Subdivision | |
No Subdivision |
Now you have a better understanding of the dynamic shape creation process. In the next sections, you'll explore street drawing, editing streets and curves, and generating street models.
Working with streets
In the previous sections, you used the dynamic city layout tools to create a street network, practiced cleaning up streets, and worked with aligning terrain. Now, you'll learn some common workflows working with streets.
Draw streets manually
First, you'll explore drawing streets using both the Polygonal Street Creation and Freehand Street Creation tools.
- To add streets to the existing network, click the Polygonal Street Creation tool (G) on the toolbar.
- Snap and click to place the first node of the new street.
- Double-click to finish the street.
You can set the segment lengths and other properties in the Polygonal Street Creation tool options window . See Draw a polygonal street for more information.
- Snap and click to place the first node of the new street.
- To draw streets by freehand, click the Freehand Street Creation tool (Shift+G) on the toolbar.
- Snap and click and drag to start drawing a new street.
- Release the mouse button to finish the street.
You can set the street widths and other properties in the Freehand Street Creation tool options window . See Draw a street freehand for more information.
- Snap and click and drag to start drawing a new street.
Curved segments
Next, you'll practice changing street segments from straight to curved and vice versa.
- Select some streets.
- Play around with the Graph > Set Curves Straight and Graph > Set Curves Smooth tools in the main menu.
The streets can be switched between straight and curved with these tools. The following image, is a good example of the differences between the Set Curves Straight and the Set Curves Smooth tools.
You can adjust the curvature of the streets with the handles. See Straight vs smooth for more information.
Note:
Keep in mind that curved streets produce many polygons so it's recommended that you keep them at a minimum. - Edit the precision of the number of segments for the curved street you created.
- Select the street and click the Precision parameter in the Inspector.
The Precision parameter value is set to .5
- Change the value to .25.
- Select the street and click the Precision parameter in the Inspector.
Edit streets
Continuing, you'll edit streets and curves using the Edit Streets/Curves tool .
- Click the Edit Streets/Curves tool (C) on the toolbar.
See Edit street and curves for more information.
- Using the handles, edit the widths of the streets and sidewalks.
- Edit the tangent handles.
Depending on the viewing angle, the horizontal or vertical tangent handles display to be edited.
Generate street models
Finally, you'll finish by generating street models with the Street Construction Simple.cga rule.
- Expand the Streetnetwork layer and right-click the Network sublayer.
- Right-click Select Objects.
This selects only the streets and not the blocks.
- Drag the Street Construction Simple.cga rule onto the selected shapes.
Street models and 3D objects are generated by the rule.
Note:
You can edit the streets, including the lengths, widths, and curves, and regenerate models on the fly.
- Select a street shape and click the Start Rule link in the Inspector.
This allows you to explore the rule in the CGA Editor.
The diagrams below demonstrate the StartRules and the corresponding street shapes by color.
Note:
You can explore the color shapes more by applying the color_streetshapes.cga rule to the streets.
Open the Part_5_End.cej scene to see the finished scene.
To learn about importing streets, see Tutorial 4: Import streets.
In this tutorial, you've explored creating terrain, growing streets automatically, cleaning up streets, aligning terrain, and creating dynamic city layouts. You then learned about drawing streets, editing them, and generating street models.
To continue your learning with CityEngine, see the complete CityEngine tutorial catalog.