Creating 3D Cityscapes Using Open-Source GIS and Open Data

Selasi Dorkenoo

This workflow has three major steps:

  1. Data Retrieval (OpenStreetMap, Scholars GeoPortal, City of Toronto Open Data Catalogue)
  2. Processing Geospatial Data (QGIS with Qgis2threejs)
  3. Combining STL Files (Autodesk Meshmixer)

(1) Use a mapping service, such as OpenStreetMap, to check the extent of the area to be modeled.

A road network shapefile as well as building footprint shapefile (polygons) with a building height (or Z) attribute will be needed. The Road Network File from Statistics Canada (via Scholars GeoPortal) and 3D Massing file from the City of Toronto Open Data Catalogue can be used. In other cases, building footprints can be extracted from OpenStreetMap and made 3-dimensional with LiDAR data and other workflows (i.e. 3dfier).

(2) Open the building footprints and road network in QGIS Desktop. Change the Coordinate Reference System (CRS) to the appropriate projection (NAD83 / UTM zone 17N for the Toronto area) and enable ‘on the fly’ transformation.

Zoom in to the subject area. In this case, the central part of the Ryerson campus was modeled, bordered by Yonge St, Jarvis St, Gerard St E and Dundas St E.

Three STL ‘layers’ will be created using this process, stacked by adjusting Z-coordinates and combined in 3D editing software: a road base, a road cut-out, and a building layer.

Create a shapefile (Layer > Create Layer > New Shapefile Layer) that encompasses the area to be modeled. This shapefile will be used for the base and road cut-out layers.  Change the type to polygon. Set the appropriate projection and add height field to the field list so that the road layer can be extruded. Click OK.

Right-click the new layer in the Layers Panel and select Toggle Editing. Use the Add Feature tool (Edit > Add Feature) to draw a polygon around the roads and buildings of the subject area.

Right click on the last node to enter the attributes for the fields (id = 1 and height = 10). Click OK

Right click the layer in the Layers Panel to save the edits, then turn off Toggle Editing.

Select the 3D Massing file in the Layers Panel. Use the Select by Polygon tool to select the buildings in the subject area.

Right click on the layer to export (Save As). Click Browse to choose where to save your file and name it. Make sure to change the CRS to the same one as the project (and polygon). Check the Save only selected features box. Click OK.

Repeat with the road network layer. Remove the 3D Massing and original road network layer, leaving only the features intersecting with the base road layer (subject area) in the project.

Use the Dissolve tool (Processing > Toolbox) on the road network to combine the road segments.

Then use the Clip tool on the dissolved output layer to clip the roads to the base road layer.

Delete the dissolved and road network layers, leaving the clipped roads, base road layer and buildings layers in the project.

Use the Fixed distance buffer tool to create a buffer around the clipped road network. Set the distance parameter to 5 and Run.

Clip the buffer output to the base road layer.

Use the Symmetrical difference tool to create the final road cut-out layer. Select the base road polygon as the Input layer and the clipped road network buffer as the Difference layer.

The result should be a polygon of the base, but with the buffered roads. Remove any unnecessary layers, leaving the buildings layer, road cut-out and base road layer.

In the Plug-In Repository (Plugins > Manage and Install), install and enable the Qgis2threejs plug-in. This plug-in will allow us to create STL files using the 2D layers in the project. Select FileExport.html as the Template file.

Since a Digital Elevation Model was not used, the features are all laying on a flat plane at an elevation of 0. Therefore, we can stack the layers by adjusting the Z coordinate parameter. The Height parameter selects the extrusion field (for instance, the height of a building or thickness of the road layer). Begin with the bottom-most layer, the base road layer, and work upwards. Select and change the parameters for each layer before running the plug-in.

Select the base road layer.

Object type: Extruded

Z coordinate – Mode: Relative to DEM, Height : 0

Style – Height: “height”, Multiplier: 1

Feature: All features

Select the road cut-out layer (Symmetrical difference).

Object type: Extruded

Z coordinate – Mode: Relative to DEM, Height : 10

Style – Height: Fixed value, Value: 5

Feature: All features

Select the building layer. In this case, the AVG_HEIGHT field represented the height of each building in the layer.

Object type: Extruded

Z coordinate – Mode: Relative to DEM, Height : 15

Style – Height: “AVG_HEIGHT”, Multiplier: 1

Feature: All features

Click Run. A browser window should open, with download links for each STL file. Download all of the STL binary files, excluding the Flat Plane.

(3) Open Meshmixer Desktop and import all three STL files. They should be stacked one on top of another. Right-click and hold to pan and scroll to control the zoom. Other camera controls and hotkeys for Meshmixer can be found here.

Use the Shift or Control key to select all three layers in the Object Browser. Combine the layers into one object by using the Combine tool.

Once combined into one object, export the cityscape (File > Export) and select STL Binary Format (*.stl) as the file type. The cityscape can now be 3D printed or shared.