CGA Code for Street Network

1928
5
04-19-2017 09:19 AM
NikosTziokas
New Contributor II

Hello CE Community!
Through ArcGIS Desktop I have separated the Road Network into:
1) Main Road
2) Substitute Road
3) Only for pedestrians.
Also I have the Building Blocks.
I would like to ask what code do I need to write, in order the Street Net to be presented presented in 3D shape.
Thank you!

0 Kudos
5 Replies
CherylLau
Esri Regular Contributor

There are some rules for streets and buildings in ESRI.lib, which is included with CityEngine.

* ESRI.lib/rules/Streets/Street_Modern_Standard.cga

* Street_Modern_Simple.cga

* Building_From_Footprint.cga

Also, there is David Wassermans Complete Streets rule.

Or, you can write your own rules based on your own specific needs.

DavidWasserman
Occasional Contributor III

The Complete Street Rule can be found here for reference:Complete Street Rule Update 
Let me know if you have any questions. 
As a side note relating to using an imported street network, make sure that your network has a clean and simplified topology as much as possible (just to reduce the work you might need to do in CityEngine). You will likely need to clean up the network in CityEngine after import, and the documentation provides some details on this process as well.
Cleanup Graph Networks  

David Wasserman, AICP
NikosTziokas
New Contributor II

Thank you all for your replies. However I have just figured out that I have to work in a different way.
I have got the Primary Schools and the Street Network of a city in a .shp file type. Each Road leads to a specific school (this was primarily the way to categorize the Street Network). Therefore 2 research questions are arising:
1) Does CE provide the possibility of visualization of the Street Network based on the afforementioned categories?
2) If so, how can I visualize those categories in the 3D Street Network view?
I have used  ArcMap software to split the Street Network in categories. After that I have uploaded the .shp file in CE.
My first thought is to visualize the Street Network ( I do not have to define the Traffic Lanes). I also have measured the Width & Length of the Roads. Does CE keep the categories being defined in ArcMap during the visualization progress?

0 Kudos
CherylLau
Esri Regular Contributor

I'm not sure what the capabilities of ArcMap are, but if you can export your data so that you can store an object attribute that marks a shape as being in a certain category, then you can write a rule that connects to this attribute and behaves accordingly.  For example, if each shape has an object attribute called category, you can write a rule that has an attribute also called category and then link this rule attribute to the object attribute in the inspector (Inspector -> drop down arrow next to rule attribute -> Connect Attribute -> Object Attribute).  Then, to visualize the streets based by their categories, in your rule you can color the streets based on category, for example.

0 Kudos
DavidWasserman
Occasional Contributor III

Hi Nikos, 

From a GIS perspective, the short answer is CE preserves these attributes but does not intrinsically know what to do with them. You can make or modify a rule to visualize street based on your research categories (as Cheryl suggested), but you can also select those  streets that match a specific category and color code them/change them per that category. I usually do this when making batch edits based on functional classification (similar to what you are doing now). For example, if you have a bunch of streets in a "traffic calming" category as your streets get closer to a school, then maybe you select every street in that category and add high visibility crosswalks and narrow the lane widths. Or you just set their color to something unique for visualization purposes.  How detailed do you want your streets to be? 


If you have street widths/lanes information it makes sense to provide that information in a form that matches the street object/rule attributes you are using. This makes them automatically map to the rule of interest on import.

# --------------------------------
# Name: CESelectLayerByAttribute.py
# Purpose: Select an object by an attribute in CityEngine.
# Current Owner: David Wasserman
# Last Modified: 12/22/2015
# Copyright:   (c) Co-Adaptive
# CityEngine Vs: 2015.2
# Python Version:   2.7
# License
# Copyright 2016 David J. Wasserman
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# --------------------------------

# Import Modules

from scripting import *

# get a CityEngine instance
ce = CE()
# Declare variables
fieldName = "Crosswalk_End"
fieldValue = "ladder"


# Main Function

def selectObjByAttribute(attr, value):
    layers = ce.getObjectsFrom(ce.scene, ce.isLayer)
    print(
        "There are " + str(len(layers) - 2) + " layers in the current scene.")  # -2 To remove Panorama and Scene Light
    counter = 0
    print("Iterating through all layers")

    print("Collecting objects from scene.")
    selectedLayers = []  # Selection is an empty list to hold all our slection
    for layer in layers:  # for loop iterates through all objects in scene
        print("Checking objects in layer ", layer)
        objectList = ce.getObjectsFrom(layer)
        for object in objectList:
            attrvalue = ce.getAttribute(object, attr)  # attrvalue gets assigned to it a retrieved attribute
            print("The current layer is:", layer)
            if attrvalue == value:  # if the attribute equals our value
                selectedLayers.append(layer)  # append the attribute value pair to the list selection
                print("Matched Attribute at value", value, " layer Added to selection.")
                break

    ce.setSelection(selectedLayers)  # set the selection equal to the list we just made
    ce.waitForUIIdle()


if __name__ == '__main__':
    selectObjByAttribute(fieldName, fieldValue)
    pass
David Wasserman, AICP
0 Kudos