Original User: matthiasbuehler
Hi !
I've been asked the following and decided to make a quick mini tutorial of this :
How can I import and use my GIS data [ Building Height, Ground Floor Height, Upper Floor Height ] in CityEngine ?
There's a zipped folder attached to this post containing a GDB and a CGA rule file. The GDB contains 3 shapes with specific attributes :
BuildingHeight
UpperFloorHeight
GroundFloorHeight
1]
Once downloaded and unzipped, just copy the GDB folder, then paste it in the 'data' folder of a CityEngine project. From there, you can drag-n-drop the GDB directly into the viewport to import the data (CE 2011.2 or newer).
2]
The FGDB Import dialog will fire up and show you there's one shape layer contained, using the an UTM projection. Click Finish.
3]
If the scene is empty and no SCS (Scene Coordinate System) has been set, an other window pops up which asks to select the SCS, click okay to accept the proposed WGS84 UTM projection. You'll see 3 shapes in your scene.
4]
Select one shape and check the Inspector : There's a tab called Object Attributes. You'll note there's the 3 attributes with the values from ArcGIS ! (yay !)
5]
Copy-paste the CGA rule provided into the 'rules' folder of your project. Double click it to open it and check the code.
6]
Select all 3 shapes in the viewport, then drag-n-drop the CGA rule file from the Navigator directly into the viewport onto the shapes. You'll notice that automatically, the buildings are extruded, then split properly into GroundFloor and as many Upperfloors as possible.
If you follow the steps above, you'll notice that :
- Nevertheless that in the CGA rules, all attributes have a value of zero to initialize the attribte in the rules, the buildings are extruded correctly to the height which is defined in the Object Attibutes !
- When there's a '@StartRule' Decoration set at a specific rule name (usually 'Lot'), the CityEngine automatically checks all attributes available when a rule file is assigned to a shape (e.g. via drag-n-drop) and points to the correct source.
- In our specific example, the CityEngine thus automatically connected the attribute value to the Object Attributes as the source, not the rule value.
Explanations and things to know (Note down !) :
We learn from this that if the CityEngine does not use the attribute values from the GIS data (Object Attributes), but use the value in the rules (in our case, nothing would be extruded since the value was defined as 0), the attribute source is not set correctly. To fix this, just use the attribute connection editor by clicking on the little icon with the black triangle next to the attribute value.
Using this workflow, you can define attributes directly in ArcGIS and then have the CityEngine use those values to drive the building generation.
Use this to colorize buildings, define tree species, roof types, ...
Cheers !