Creating a city model with random heights

657
2
11-08-2017 08:13 AM
YigalMuntner
New Contributor III

I'm trying  to create a model by importing osm data through the wizard. The problem is that in my area of interest buildings have no height information. The default rule creates random heights with very high buildings. How can I control the maximum height of a building inside the CGA rule? thanks, Yigal

Tags (1)
0 Kudos
2 Replies
CherylLau
Esri Regular Contributor

You can create a wrapper rule for the Building_From_OpenStreetMap.cga rule in order to define your own styles.  In your style, you can control the height of the buildings.  You cannot set the max height of a building, but you can set the number of floors and the floor height.  This wrapper rule can be placed in any project; it does not need to be in the ESRI.lib folder.

For example, here is a wrapper rule that defines a style called MyStyle which creates buildings with a random number of floors in the range [20,100] (if the height is not specified already by an object attribute from OSM data).  The number of floors is set by setting the attribute estimatedLevels on line 73.  In the Style section, you can add your own style which sets any of the attributes that start with "estimated".  Do not make changes to the Hidden Attributes section.

import Building_From_OpenStreetMap:"/ESRI.lib/rules/Buildings/Building_From_OpenStreetMap.cga"


// ------------------------------
// Hidden Attributes
// ------------------------------

@Group("From Object Attributes", 2)

// from object attributes
@Hidden
attr height = -1
@Hidden
attr building__levels = -1
@Hidden
attr roof__height = -1
@Hidden
attr roof__shape = ""
@Hidden
attr building__colour = ""
@Hidden
attr roof__colour = ""

@Group("Estimated Attributes (can be set by styles)", 3)

// Note: These attributes can be overriden by styles.
// estimated attributes based on default values or overriden by styles
@Hidden
attr estimatedLevels = Building_From_OpenStreetMap.estimatedLevels
@Hidden
// possible options: "flat", "shed", "pyramid", "gable", "hip", "half-hip", "gablet", "gambrel", "mansard", "gambrel-flat", "mansard-flat", "vault", "dome", "saltbox", "butterfly"
attr estimatedRoofForm = Building_From_OpenStreetMap.estimatedRoofForm                                   // when no obj attr roof__height
@Hidden
// possible options: "flat", "shed", "pyramid", "gable", "hip", "half-hip", "gablet", "gambrel", "mansard", "gambrel-flat", "mansard-flat", "vault", "dome", "saltbox", "butterfly"
attr estimatedNonFlatRoofForm = Building_From_OpenStreetMap.estimatedNonFlatRoofForm               // when obj attr roof__height>0
@Hidden
attr estimatedFloorHeight = Building_From_OpenStreetMap.estimatedFloorHeight
@Hidden
attr estimatedNonFlatRoofHeight = Building_From_OpenStreetMap.estimatedNonFlatRoofHeight
@Hidden
// possible options: "extrusion", "setback top", "setback facade", "setback base", "setback everywhere"
attr estimatedBuildingForm = Building_From_OpenStreetMap.estimatedBuildingForm
@Hidden
// format: hex color string
attr estimatedBuildingColor = Building_From_OpenStreetMap.estimatedBuildingColor
@Hidden
// format: hex color string
attr estimatedRoofColor = Building_From_OpenStreetMap.estimatedRoofColor
@Hidden
// possible options: "realistic with facade textures", "schematic facades", "solid color"
attr estimatedRepresentation = Building_From_OpenStreetMap.estimatedRepresentation


// ------------------------------
// Start Rule
// ------------------------------

@StartRule
Lot -->
     Building_From_OpenStreetMap.Generate
     
     

// ------------------------------
// Styles
// ------------------------------

// Add your own styles here by setting the attributes that start with "estimated"

     
style MyStyle

attr estimatedLevels = rint(rand(20,100))
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Apply this wrapper rule to your building footprints and choose the style MyStyle.  Note that you cannot choose one of the preset styles in the Building_From_OpenStreetMap file, such as GenericMediumTown, NewYork, or Vancouver.  The Building_From_OpenStreetMap style must be set to the Default Style.  Otherwise, the style chosen in Building_From_OpenStreetMap will take precedence over any style set in the wrapper file.

YigalMuntner
New Contributor III

Thanks a lot Cheryl, this was very helpful.

Yigal

0 Kudos