Import DXF street data
CityEngine street networks
CityEngine street networks are attributed graphs, consisting of graph nodes (crossings) and graph edges (street segments). They can be generated with the street grow feature, created in CityEngine, or imported via an external file, such as DXF.
Prepare street data for CityEngine
In this example, the main road structure for a seaside city has been sketched in Illustrator using its path and geometry tools.
Export a DXF file from external CAD applications
When exporting the street network, make sure the units fit the CityEngine unit system, which always interprets numbers in imported files as meters. You can open the .dxf in a text editor and look for the vertex data to see what dimensions are written out. In this example, an export scale of 1 pixel equals 10 units is set to get the needed dimensions (see the export options screen shot below).
The following is vertex data generated by the DXF export operation:
... AcDb2dVertex 10 1244.99951171875 20 234.998046875 30 0.0 0 VERTEX ...
The following screen shot shows suggested options in the Illustrator DXF/DWG Options dialog box:
Import a DXF file into CityEngine
- Open the sesame_01.cej scene file.
- Locate the sesame_streetsketch.dxf file in the data folder.
- Right-click the file, and choose Import.
The Layer 2 data layer is already added as a graph layer to be imported.
- Make sure Run Graph Cleanup Tool after Import is checked, and click Next.
- Enable Intersect Segments, Snap Nodes to Segments, and Merge Nodes.
- Set the snapping distance to 1 and the merging distance to 5.
- Click Finish.
A new graph layer called sesame_streetsketch appears in the Scene Editor. Alternatively, you can open the sesame_02.cej scene file to get the scene with the imported data.
Grow minor streets
Once the major streets are imported, you can start to refine the street network and grow the minor streets in between. The Street Grow Algorithm in CityEngine tries to fill existing closed blocks, so you can iteratively fill the street blocks with streets.
- Focus the street block you want to create minor streets.
- Create two single small streets using the graph edit tool.
- Manually create some street segments.
- Select the segments (q key), and fill in the blank areas using the Grow Streets dialog box.
The sesame_12.cej scene file contains a finished street network with extracted and subdivided lots.
The following screen shot shows Sesame City with generated minor streets and extracted building footprints:
The following screen shot shows Sesame City with simple buildings and vegetation models:
Import OSM street data
"OpenStreetMap is a project aimed squarely at creating and providing free geographic data such as street maps to anyone who wants them." — openstreetmap.org
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 the 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.
Export an OSM file from OpenStreetMap
The OSM data for this tutorial (area of historical Pompeii) was downloaded from api.openstreetmap.org/api/0.6/map?bbox=14.4798600,40.7454200,14.4984500,40.7550800.
Find the .osm file in the data folder of your current CityEngine project.
Import an OSM file into CityEngine
- Open a new scene file by clicking File > New > CityEngine > CityEngine scene.
- Drag the file into the 3D viewport.
- In the OSM import dialog box, choose the layers to import. Typically, all streets are in the highway layer and buildings are in the building layer. Use the Select/deselect all check box to deselect all layers if necessary.
- Set the additional options as shown in the following screen shot:
- Click Finish.
- Accept the suggested coordinate system WGS 1984 UTM Zone 33N.
- Click OK.
- Rename the graph network layer to OSM_Streets.
- Rename the shape layer to OSM_Shapes.
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 OSM street types.
Select a street segment and note its parameters in the Inspector.
In the following screen shot, a street with highway type primary has assigned street and sidewalk width parameters according to the layer attribute mapping from the imported OSM Layer OSM_Streets:
You can manually modify the street width by setting a new width value to the streetWidth parameter (the value will change to a user-set value) or by using the Street Edit tool on the toolbar.
OSM attribute mapping
- Select the new graph network layer in the Scene Editor, and look at the layer attribute code in the Inspector.
The street segment in the previous image is of type tertiary and is mapped to 6 meters in the function streetWidthByClass. You can change the mapping here as desired.
#2012.1 //------------------------- // Example OSM Tag Mapping streetscale = 1 // street width scale factor width = getObjectAttr("width") lanes = getObjectAttr("lanes") attr streetWidth = // street width depending on available attributes case width > 0 : width * streetscale case lanes > 0 : lanes * 3 * streetscale else : streetWidthByClass * streetscale * one-way class = getObjectAttr("highway") 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 one-way = // one-way width correction case getObjectAttr("one-way") == "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
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. There are a number of ways to deal with such conflicts:
- Use the Cleanup Graph tool with different parameters.
- Select fewer streets from the highway layer in the import dialog box.
- Set 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 screen shots show an example of unconnected graph nodes before and after cleaning:
Add a map layer with georeferenced satellite imagery
- Click File > Import > CityEngine Layers > Texture Import.
- 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 Size (bounds) and Offset (location) parameters are automatically set. See world file raster datasets for more information.
- Click Finish to create the new texture map layer.
- Select all shapes in the OSM_Shapes layer in the Scene Editor..
- Assign the osm_generic.cga rule file.
Because some shapes already have a valid start rule set, the Set Start Rule dialog box appears.
- Click Skip.
- Click Generate.
As you may have noticed, only the streets have been generated. The building shapes were not generated. Select one of them and note in the Inspector that there is no start rule assigned.
- To fix it, right-click the selected shape in the viewport and choose Select > Select Objects with Same Start Rule from the context menu. This selects all shapes with no start rule set.
- In the Inspector, click the Select button next to the Start Rule field.
- In the Set Start Rule dialog box, choose Lot.
- Click Generate again.
Import shapefile (and geodatabase) street data
Because the operation of importing streets from shapefiles and geodatabase files is almost identical, a specific example for geodatabases is not shown here.
- Locate the streets.shp file in the data folder of the tutorial project.
- Create a new empty CityEngine scene.
- Drag and drop the streets.shp file from the Navigator into the 3D viewport.
- During import, CityEngine prompts you to choose a scene coordinate system. The projection defined for the shapefile is suggested as default; use that here.
The imported street shapes show some conflicting street shapes, marked with red dotted lines. Use the Cleanup Graph operation with Resolve Conflicting Shapes enabled to fix those automatically. You can also use the Simplify Graph tool to reduce unneeded complex graph segments by approximating the graph by deleting unneeded graph settings and setting the tangents. See the Street Network section of the CityEngine manual for details.
Assign rule file
- Select all street shapes.
- From the File Navigator, drag the sesame_01.cga rule file from the projects rule folder onto the selected shapes in the 3D viewport.