Tutorial 4: Import streets

To access the tutorial projects in ArcGIS CityEngine, open CityEngine and click Help > Download Tutorials and Examples in the main menu. After choosing a tutorial or example, the project is automatically downloaded and added to your CityEngine workspace.

Vegetation models added to Sesame City

CityEngine street networks consist of graph nodes (intersections) and graph edges (street segments). They can be generated with grow street tools, manually drawn in CityEngine, or imported from external files, such as DXF or SHP files.

The example below shows the main road structure for a seaside city that was sketched in Adobe Illustrator.

Exported DXF of seaside road network

It was then exported as a DXF file to import into CityEngine.

Note:

When exporting a street network as a DXF, ensure you convert the units of the application to meters since the CityEngine coordinate system is in meters.

In this tutorial, you'll learn and explore importing streets for different data types.

Import a DXF file

To import a DXF file into your scene, do the following:

  1. Expand the Tutorial_04_Import_Streets tutorial folder in the Navigator window.
  2. Open the sesame_01.cej scene in the \scenes\ folder:

    The seaside texture shows in the scene.

    Seaside texture

  3. Right-click the sesame_streetsketch.dxf file in the data folder and select  Import.

    You can also select the .dxf file and click File > Import in the main menu.

    DXF import dialog box

    The Graph box shows that the Layer 2 data is added as a graph layer to import.

  4. Ensure that the Run Graph Cleanup Tool after Import and Create Street/Nodes Shapes from Graph check boxes are checked, and click Next.
  5. Check the Intersect Segments, Snap Nodes to Segments, and Merge Nodes check boxes.
  6. Set the Horizontal Snapping Distance and Vertical Snapping Distance values to 1.
  7. Set the Horizontal Merge Distance and Vertical Merge Distance values to 5.

    The Cleanup Graph settings should look like the following:

    DXF import cleanup graph

  8. Click Finish.
  9. Rename the new street layer to Sesame Street Sketch in the Inspector window.
  10. Turn off the grid in the Viewport window by pressing (D+G) or click Grid under the View settings tool View settings.

    Imported DXF in Viewport

    Open the sesame_02.cej scene in the scenes folder to see the imported DXF next to the seaside.

Grow the minor streets

Once the major streets are imported, you can start to refine the street network and grow the minor streets in between. Next, you'll use the Grow Streets tool to fill existing closed blocks to iteratively fill the street blocks with streets.

  1. Keep the sesame_02.cej scene open.
  2. Use the Select tool Select tool to select one of the main street segments inside the main street ring.

    This specifies the general orientation of the streets in the block and defines a starting node for the grow street algorithm.

    Street selected to grow streets

  3. Click Visibility settings Visibility settings and select Shapes, or press F11, to turn off the shapes visibility.

    You do this to isolate the major and minor streets in the street network.

  4. Click Graph > Grow Streets in the main menu to open the Grow Streets dialog box.
  5. Click Radial on the drop-down menu next to Pattern of minor streets.

    Pattern of minor streets set to Radial

  6. Click Apply.

    The minor streets generate in a radial pattern.

    Minor streets in a radial pattern

  7. To continue growing the minor streets, select another street.

    Street selected in radial street pattern

  8. Keep the same settings and click Apply.

    Streets grown in a radial pattern

    Streets are only grown inside the ring. The sesame_03.cej scene shows the finished radial street pattern.

  9. Create streets in a different part of the street network to continue growing streets.

    Use the Polygonal Street Creation tool Polygonal Street Creation tool to add two new streets and keep them selected.

    Streets created for street growth

  10. This time, change the Pattern of minor streets setting to Raster.
  11. Click Apply.

    The streets are generated from the selected streets with the minor streets in a raster pattern.

    Streets grown with minor streets in a raster pattern

    You can change the settings to get different street patterns when growing streets. See Street pattern examples for more information.

Generate building and vegetation models

The sesame_12.cej scene shows the finished scene from above. After applying the grow streets algorithm multiple times, there are generated major and minor streets and extracted building footprints. Next, you'll generate the building and vegetation models.

  1. Open the sesame_12.cej scene.

    Sesame City network of streets and buildings

  2. Click No when asked if you want to generate models.
  3. Right-click the streets final layer and click Select Objects.
  4. Click the Generate button Generate(Ctrl+G) to generate all the building and vegetation models.

    Vegetation models added to Sesame City

Import OSM data

OSM is an XML-based format used to describe vector data in a map. It defines three basic data types—nodes, ways, and closed ways—which are used to describe all other elements:

  • Nodes—Points between which segments are drawn.
  • Ways—Ordered list of nodes, displayed as connected by line segments in the editor.
  • Closed Ways—Ways that go in a complete loop. They are used to describe areas such as parks, lakes, or islands.

Now, you'll work with importing OSM data.

To import an OSM file, do the following:

  1. Open a new scene file by clicking File > New > CityEngine > CityEngine scene.
  2. Drag the .osm file in the data folder into the Viewport window.
  3. In the OSM import dialog box, choose the layers to import.

    Typically, the streets are in the highway layer and the buildings are in the building layer. Use the Select/deselect all check box to deselect all layers if necessary.

  4. Set the additional options as shown in the image below:

    OSM import dialog box

  5. Click Finish.
  6. Keep the Scene Coordinate System set to WGS 1984 UTM Zone 33N.

    Scene coordinate system dialog box

    See Scene coordinate systems for more information.

  7. Click OK.

    Two new layers, the street network and shapes layers, appear in the Scene Editor window. The OSM data is visible in the viewport, displaying automatically created street shapes on the imported street centerlines.

    Imported OSM streets and shapes

  8. Rename the graph network layer to OSM_Streets in the Scene Editor window.
  9. Rename the shape layer to OSM_Shapes.

Note:
You can also use the Get Map Data tool in CityEngine to import OSM data from a selected region in the world. See Get map data for more information.

Street widths

If you look closely at the generated street shapes, you'll notice that they differ in width. When importing OSM data with the Map OSM tags option enabled, CityEngine creates layer attributes that define street widths from the OSM street types.

Select a street segment and note its parameters in the Inspector window.

Street with layer attributes

The selected street has the highway parameter set to primary, and the street and sidewalk width parameters are defined according to the layer attribute mapping from the imported OSM_Streets layer.

You can manually modify the street width by setting a new width value in the Segment Width parameter (the value will change to a user-set value) or by using the Edit Streets/Curves tool Edit street/curves tool (C).

OSM attribute mapping

To see the OSM street data layer attributes, select the OSM_Streets layer in the Scene Editor window and explore the layer attributes under Layer Attributes in the Inspector window.

For example, the selected street segment in the previous image is set to primary and the street width is mapped to 8 meters in the streetWidthByClass function. You can modify the mapping in Layer Attributes.

//------------------------- 
// Example OSM Tag Mapping

streetscale = 1 // street width scale factor

width = getFloatObjectAttr("width", false)
lanes = getFloatObjectAttr("lanes", false)

attr streetWidth = // street width depending on available attributes
    case width > 0 : width       * streetscale
    case lanes > 0 : lanes * 3.5 * streetscale
    else           : streetWidthByClass * streetscale * oneway

class = getStringObjectAttr("highway", false)

streetWidthByClass =
    case class == "primary"     : 8
    case class == "secondary"   : 7
    case class == "tertiary"    : 6
    case class == "motorway"    : 12
    case class == "trunk"       : 11
    case class == "road"        : 6
    case class == "residential" : 5
    case class == "footway"     : 2
    case class == "cycleway"    : 2
    case class == "steps"       : 2
    else                        : 4

oneway = // oneway width correction
    case getStringObjectAttr("oneway", false) == "yes" : 0.5
    else                                               : 1

sidewalkscale = 1 // sidewalk width scale factor

sidewalkWidth =
    case class == "primary"     : 2
    case class == "secondary"   : 2
    case class == "tertiary"    : 2
    case class == "residential" : 2
    else                        : 0

attr sidewalkWidthLeft  = sidewalkWidth * sidewalkscale
attr sidewalkWidthRight = sidewalkWidth * sidewalkscale

Data conflicts

Imported OSM data often is not very clean and leads to conflicts (for example, overlapping streets). Open blocks or red dotted lines are indications of unconnected segments or overlapping streets, which can lead to invalid blocks. You can resolve the conflicts in the following ways:

  • Use the Cleanup streets tool Cleanup streets tool.
  • Select fewer streets from the highway layer in the import dialog box.
  • Set the street and sidewalk widths to lower values (resulting in less overlapping streets).
  • Manually clean up the street network after import by combining or removing nearby crossings or parallel streets.

The following images show an example of unconnected graph nodes before and after cleaning:

Unconnected graph nodes before cleaning
Unconnected graph nodes after cleaning

Note:

OSM street data usually contains elevation data (attribute level), but it may be faulty. If you activate the Run Generate Bridges Tool option, CityEngine automatically works out a possible solution to deal with this.

Add a map layer with georeferenced satellite imagery

Next, you'll add a georeferenced aerial image to the scene.

  1. Click File > Import > CityEngine Layers > Texture Import.
  2. Browse to the pompeii_satellite.tif file in the \maps\ folder.

    The pompeii_satellite.tfw world file accompanies the pompeii_satellite.tif file and stores the georeference information for the image. Therefore, the Dimensions and Location parameters are automatically set. See World files for raster datasets for more information.

    Import texture dialog box

  3. Click Finish to create the new texture map layer.

    OSM data with GeoTIFF

Note:
CityEngine does not reproject images on import. Choosing the coordinate system on image import is only used to calculate the correct location information. Therefore, it necessary to have the image data prepared in the projection used in the CityEngine scene. In the previous example, the Pompeii satellite image was reprojected to WGS 1984 UTM Zone 33N (the Scene Coordinate System used for this tutorial scene).

Generate models

Finally, you'll generate models from the OSM shapes.

  1. Select all the shapes in the OSM_Shapes layer in the Scene Editor window.
  2. Drag the osm_generic.cga rule file onto the selected shapes.

    Because some shapes already have a valid start rule set, the Set Start Rule dialog box appears.

    Set Start Rule dialog box

  3. Select the Lot rule.
  4. Click OK.

    Generated models from OSM shapes

Import SHP and GDB data

You can also import shapefiles (SHP) and geodatabase (GDB) data into CityEngine. Because the operation of importing streets from shapefiles and geodatabases is almost identical, a specific example for geodatabases is not shown here.

Import shapefile data

To import the shapefile, do the following:

  1. Create a CityEngine scene.
  2. Drag the streets.shp file located in the data folder into the Viewport window.

    The shapefile also has a .prj file, which ensures correct georeferencing on import. The data consists of polylines that import as street segments in CityEngine. The data also contains the width attribute, which controls street width.

  3. During import, CityEngine prompts you to choose a scene coordinate system.

    Shapefile scene coordinate system dialog box

  4. Keep the scene coordinate system as WGS 1984 UTM Zone 11N and click OK.

    Imported shapefile

    Note:

    The .shp data in this example contains the width attribute to control the street width. If the shapefile doesn't have the width attribute, default street widths are automatically assigned. Also, street widths can be set manually after import. Mappings to other attribute names are also possible using attribute mapping.

Cleanup

The imported street shapes show some conflicting street shapes, marked with red dotted lines.

Conflicting street shapes marked with red dotted lines

Use the Cleanup streets tool Cleanup streets tool with Resolve Conflicting Shapes enabled to fix those automatically. You can also click Graph > Simplify Graph to reduce the number of complex graph segments by deleting unnecessary ones and setting the tangents. See Cleanup streets for more information.

Assign rule file

Finally, you'll assign rules to generate street models:

  1. Select all street shapes.
  2. Drag the sesame_01.cga rule file onto the selected shapes in the Viewport window.

    Streets before the models generated
    Streets are shown before the models are generated. See the shp_01.cej scene.
    Street after models generated
    Streets are shown after the models are generated. See the shp_02.cej scene.

In this tutorial, you learned how to import streets for different data types, including DXF, OSM, and shapefiles.

To continue your learning with CityEngine, see the complete CityEngine tutorial catalog.