GIS Data Mini Tutorial : Building Height and Floor Splits

5367
13
03-15-2012 03:33 AM
by Anonymous User
Not applicable
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 !
13 Replies
MaryKodama
New Contributor
Thanks for the tutorial!  I've been searching for rules about assigning the building facade.  What are the different ways to set/assign a particular side of a building as a facade? When I extrude some of my imported building footprint shape files, the facade shows up at different places.
0 Kudos
by Anonymous User
Not applicable
Original User: matthiasbuehler

hi ..

this depends on the selector of the comp(f) after you have extruded.

depending on how you split off the facades, you can assign different facade rules to each specific building side.

e.g.
comp(f) {front : FrontFacade. | side : SideFacade.}
comp(f) {front : FrontFacade. | back : BackFacade. | side : SideFacade.}
..
[[ when playing with this, please note how the side selector selects all sides which have not previously been split off by front or back. ]]

let me know if this helps !
0 Kudos
MaryKodama
New Contributor
Hi Matt,
Thanks!  I've been delving into the CGA rules for the last few weeks.  It has been a steep learning curve for a casual ArcGIS user like me who has never done any programming and is also not familiar with the syntax.    Its especially difficult when you go to the on-line manual for the definition of a particular rule and it still doesn't make any sense.  But every day I am figuring it out a bit more and more!  Anyway...thanks for all your answers on the CGA forum.  Mary
0 Kudos
by Anonymous User
Not applicable
Original User: matthiasbuehler

Hey Mary !


I'm here to help, just post any question you have and I'll try to answer as soon as possible. 🙂

It may be of interest for you to hear that I am currently working together with Esri Training Services to set up official training courses !


Cheers !
0 Kudos
KathrinSchulte-Braucks
New Contributor III
Thank you, this tutorial helped me a lot! 🙂
0 Kudos
by Anonymous User
Not applicable
Original User: sjones

Many thanks for the sample Matthias, it really is a good start to modelling user-defined types with CE.

Susan
0 Kudos
LoringTupper
New Contributor
I appreciate the tutorial, it was very helpful.
I do have a question though. I would like to set values for color and height based on an extracted GIS layer attribute value for land use. For instance, if the GIS layers PROPERTY_USE attribute indicates the land use is "C-3" then I want to set the color to red and the building height to rand(0,23). There are numerous values for PROPERTY_USE so I would want to define this in a case statement, do I do the case statement before the start rule and what exactly would the syntax be. I experimented with the code below but was unsuccessful:

# land use types
attr landuseTypeHeight = 0
attr landuseTypeColor = ""

# color declarations
red = "#ffaaaa"
green = "#aaffaa"
blue = "#aaaaff"
turquoise = "#ooebeb"
white = "#ffffff"
yellow = "#ffff73"
grey = "#9c9c9c"

# land use types ( this will be extracted from the GIS layer attribute)
attr PROPERTY_USE = ""


// Functions
landuseTypeColor(PROPERTY_USE) -->
case PROPERTY_USE == "C-2" : red
case PROPERTY_USE == "C-3" : red
case PROPERTY_USE == "C-3(23)" : red
case PROPERTY_USE == "CC-COR" : red
case PROPERTY_USE == "CC-MH" : red
case PROPERTY_USE == "C-COR1" : red
case PROPERTY_USE == "CC-X" : red
case PROPERTY_USE == "CM-1" : red
case PROPERTY_USE == "CM-2" : red
case PROPERTY_USE == "I-2" : red
case PROPERTY_USE == "RM-7" : yellow
case PROPERTY_USE == "S-CS" : red
case PROPERTY_USE == "Other" : turquoise
else : white


// calc height with variation
landuseTypeHeight(PROPERTY_USE) -->
case PROPERTY_USE == "C-2" : rand(0,23)
case PROPERTY_USE == "C-3" : rand(0,46)
case PROPERTY_USE == "C-3(23)" : rand(0,23)
case PROPERTY_USE == "CC-COR" : rand(0,80)
case PROPERTY_USE == "CC-MH" : rand(0,80)
case PROPERTY_USE == "C-COR1" : rand(0,23)
case PROPERTY_USE == "CC-X" : HEIGHT
case PROPERTY_USE == "CM-1" : rand(0,45.8)
case PROPERTY_USE == "CM-2" : rand(0,45.8)
case PROPERTY_USE == "I-2" : rand(0,12)
case PROPERTY_USE == "RM-7" : rand(0,46)
case PROPERTY_USE == "S-CS" : rand(0,12)
case PROPERTY_USE == "Other" : rand(0,12)
else: 0
0 Kudos
by Anonymous User
Not applicable
Original User: matthiasbuehler

hi !

if the code parses correct and you have no errors, but still all is 0 high and white, then there's most probably just 1 issue :

the attr source is set to 'rule' in the Inspector instead of the correct source.

Use the black/white (little triangle on a rectangle ) Connection Editor button in the Inspector to set that source correctly.


lemme know if this works.

Matt
0 Kudos
LoringTupper
New Contributor
Thanks Matt, that was the problem, the rule now executes properly.
0 Kudos