Importing Data from SHP Files


The ESRI Shapefile or simply a shapefile is a popular geospatial vector data format for geographic information systems software. A shapefile commonly refers to a collection of files. The main file (.shp) contains the shape data and the database file (.dbf) contains attributes for each shape. The shapefile importer can import shapes and attributes from these files. The .dbf must be present and must have the same base name as the .shp file.

Import Settings

The import dialog consists of several options, as shown below. As usual, presets can be saved and applied.

The shapefile import wizard.


Press Browse to open a dialog to select a .shp file to import.

After opening a file, the dialog detects the shape type of the file. The type is displayed in the header of the dialog (e.g. "Shape Type: POLYGON. Importing shapes.."). The following types can be imported as shapes: Polygon, PolygonZ, PolygonM, Multipatch, Point, PointZ. Other types are imported as graph segments.

Shapefiles containing points can also be imported. In this case, a marker (0.1x0.1m quad) is created for each point.

Shape file polygons containing "negative" polygons that cut holes into polygons are not supported yet, and will be imported as normal shapes instead of "holes".

Coordinates System

The importer reads the .prj projection file of the shapefile. If successful, the corresponding coordinate system is displayed in the dialog. Otherwise, a pop-up dialog asks the user to choose a coordinate system.

Please make sure that the input shapefiles use the same coordinate units in the planar and up directions. CityEngine does not support separate units for the planar and up directions.

Graph Settings

Note: The following settings are only of interest when importing graph networks.

Run Generate Bridges Tool after Import

If enabled, the Generate Bridges Tool is executed on a following wizard page.

Run Simplify Graph Tool after Import

If enabled, the Simplify Graph Tool is executed on a following wizard page.

Run Graph Cleanup Tool after Import

Depending on the OSM data it may be necessary to cleanup the graph segments after import. If enabled, the graph cleanup tool is executed on a following wizard page.

Create Street/Intersection Shapes from Graph

If enabled, the shape creation parameter of the graph nodes and segments will be enabled and street shapes are created.

Create Block/Lot Shapes from Graph

If enabled, the shape creation parameter of potentially created street blocks will be enabled and shapes are created.

Map Shape File Attributes

If enabled, an imported graph layer will contain the following layer attribute code:

The shape attribute mapping function code displayed in the Inspector after import.

This mapping controls the width of the street shapes generated from the graph center lines. In the default behaviour, the object attribute width is used to determine the resulting street width, and defaults to 8 if no object attribute is found.

Advanced users can edit the default mapping code by changing the cga code in the file shp.ceattr, located in /ce.lib/rules/.


Using Attributes from SHP file

A SHP file has an accompanying .dbf file that contains associated attributes for elements. After importing the SHP file, these attributes appear in the Inspector in the Attributes tab. The picture below shows two shapefile attributes height and id in the Inspector:

SHP file attributes ALTITUDE and HEIGHT displayed in the inspector.

To use these attributes with the CGA grammar you need to declare CGA attributes with matching names. A simple CGA rule file could look like this:
attr height = 10

Lot --> extrude(height)
After assigning this rule file to the shapes, the CGA attribute height appears in the CGA Attribute Mapping tab of the Inspector. Note that the Source field is set to Object, which denotes that the CGA attribute height is controlled by the object attribute of the lot.

New mapped CGA attribute HEIGHT after assigning a rule file

Copyright ©2008-2018 Esri R&D Center Zurich. All rights reserved.