Alter International City cga rule to define building type based on land type map

11-03-2018 08:42 AM
New Contributor II

Hi all

I'm trying to alter the cga rule so that i can define building type based on a land type map.

I've followed this tutorial

Tutorial 3: Map control—CityEngine Tutorials | ArcGIS Desktop 

which explains how to change the colour of buildings based on the land type.  But now i would like to use the existing International city cga rule and create the building types according to a red / green / blue map... ie.

industrial = red, residential = green, commercial= blue.

i've tried copying in the code from the tutorial into the international city cga rule but not sure how i can get the rule to select the building type based on the RGB value....

// land use types
attr t_industrial = 0
attr t_commercial = 0
attr t_residential = 0

// color declarations
red = "#ffaaaa"
green = "#aaffaa"
blue = "#aaaaff"
white = "#ffffff"

// Functions
landuseTypeColor =
case t_industrial > t_commercial && t_industrial > t_residential : red
case t_commercial > t_industrial && t_commercial > t_residential : blue
case t_residential > t_industrial && t_residential > t_commercial : green
else : white

any ideas anyone? thanks in advance


0 Kudos
4 Replies
Occasional Contributor III

Did you see this tutorial? #10 CityEngine Essential Skills: Thematic Visualization With CGA - YouTube  

Download the CityEngine Essential Skills Training - Project Files: 

0 Kudos
New Contributor II

Hi Luiz

thanks for the message, yes i've seen that one... but it styles the buildings based on footprints....

I don't have building footprints, so what i'm after is using the landuse map to define residential, commercial, industrial  areas for example.  

0 Kudos
Esri Regular Contributor

Here is an example.

1) Create a map with red (1,0,0) in areas you want the type "Highrise Building" and green (0,1,0) in areas you want the type "Residential".

2) Add map layer to scene following instructions in Tutorial 3, Section "Control the Skyline", steps 1-10.  Instead of adding the attribute called skylineValue, add an attribute called myRedValue for the red channel and an attribute called myGreenValue for the green channel.  For both attributes, the min and max are [0,1].

3) In the International City.cga rule, change the definition of getType and add two attributes:

attr myRedValue = 0
attr myGreenValue = 0

# Constants
const getType =
     case myRedValue==1:          "Highrise Building"
     case myGreenValue==1:     "Residential"
     else:                          "Open Space"

4) Select all lots and in the Inspector, connect the attributes myRedValue and myGreenValue to the desired layer attributes (the ones we created with the same name).  Steps 13-15 in Tutorial 3.

New Contributor II

thanks, i'll give this a go

0 Kudos