Extracting building height and setting color from shapefile data

1919
1
07-12-2012 12:48 AM
RomanTrubka
New Contributor
Hello,

I'm trying to get walking with City Engine and it's been slow to start. I've managed to import a Shapefile containing property boundary polygons and extrude the property boundaries according to a height attribute in the Shapefile. Now I'm wondering how I can set the StartRule to also color the buildings according to their classification in an attribute column called "land_use". The "land_use" column contains values such as "R" for "residential", "C" for "commercial", "I" for "industrial", etc. The basis of what I have is the following:

attr height = 0

@StartRule
Lot -->
extrude(height)
color("#990000")

This only lets me extrude the properties to a height specified in the "height" attribute column of the Shapefile and color the 3D model red. I have tried to include some 'case' statements with a number of color functions to evaluate statements testing the type of property listed in the "land_use" column but I've gotten nowhere with this.

I also do not understand the need for declaring the attribute "height" as equalling zero at the beginning when it should just get the value from from the "height" attribute in the Shapefile. I'm not a programmer so some of these things are putting at the beginning of a steep learning curve.

If someone could help me work some 'case' statements into the StartRule to set different colors for properties with different land uses it would be much appreciated. I would also appreciate if someone could explain the reason for line declaring the attribute "height" equalling zero.

Many thanks
0 Kudos
1 Reply
MatthiasBuehler1
Frequent Contributor
hey !


[ may contain typos ]

attr height = 0           # Link to Object Attr ( Gis data )
attr land_use = "C"     # Link to Object Attr ( Gis data )


zoneColor =                # the color function !
    case land_use == "C" :
        "#ff0000"
    case land_use == "R" :
        "#00ff00"
    else:
        "#0000ff"

@StartRule
Lot  -->
    extrude(world.y, height)
    color (zoneColor)



add more cases once it works .. 🙂 ok ?
0 Kudos