We’ve recently written blogs on visualising OS MasterMapÂ® Topography Layer Building Height Attribute (BHA) data in ESRI’s ArcGIS and ArcGlobe and also QGIS. These blogs have proved very popular so we have written a 3rd instalment on how to achieve similar results using Autodesk products using AutoCAD Map3D and InfraWorks.
Please see the previous post for information on BHA data coverage, an explanation of the different height attributes supplied by Ordnance Survey (OS) and for details of further information sources; including the excellent Getting Started Guide produced by OS. Please remember this is an alpha release of the data and OS do not guarantee that BHA is error free or accurate. Additionally the dataset is not yet subject to update and maintenance.
Download the following datasets for your area of interest from Digimap using the OS Data Download application:
- OS MasterMapÂ® Topography Layer: select â€˜GMLâ€™ as the format for your data rather than ‘DWG’ as we need to get to some of the raw data values stored in the GML file, and limit your download to just the Buildings using the Layers drop-down in the basket.
- OS Terrainâ„¢ 50 DTM: this will be used as the base (surface) heights for the area;
- BHA data (BHA data is found in the â€˜OS MasterMapâ€™ group): select CSV as the format;
- Optionally download any additional data you may wish to use as a backdrop draped over the DTM surface, in this example we’re going to use OS MasterMapÂ® 1:2,000 Raster but other datasets could be used.
Preparing BHA data for use
If your downloaded BHA data is made up of more than one CSV file we recommend merging them all together in to a single CSV file first to make subsequent processing easier and quicker. Use a text editor such as Notepad or TextPad rather than Excel, as Excel can change the formatting of numbers which contain leading zeros.
Each object in MasterMap Topography Layer has a unique identifier called a Topographic Identifier, or TOID for short. TOIDs supplied by OS take the format of a 13 or 16 digit number prefixed with â€˜osgbâ€™ e.g. â€˜osgb1000039581300â€² or â€˜osgb1000002489201973â€². Some applications, including AutoCAD Map 3D , automatically strip off the â€˜osgbâ€™ prefix and add three leading zeros to any TOID that has only 13 digits to make them all 16 characters long. In order to make it easier to join BHA data to building features in MasterMapÂ® Topography Layer the BHA files supplied by EDINA have two TOID values:
- os_topo_toid_digimapÂ is the TOID formatted to match TOIDs in AutoCAD Map 3D, ArcGIS and in the File Geodatabase format supplied through Digimap.
- os_topo_toid is the original TOID as supplied by Ordnance Survey
You should check the TOID values in your MasterMap data and those in the BHA data to ensure that there is a common field that you can use to match on; we will use os_topo_toid_digimap as this field in the BHA data matches the TOID values in the MasterMap data when used in AutoCAD Map 3D.
Open the merged CSV file in Excel. To ensure that the data is displayed correctly in Excel you should import the data as follows:
- Open a blank Excel document then use the ‘From Text’ option which can be found on the Data ribbon.Â This allows you to specify the correct field delimiter and data types for the TOID columns, ensuring they are imported as text fields, show image.
- Import the data as a ‘delimited’ file, show image.
- Specify ‘Comma’ as your delimiter, show image.
- On the Text Import Wizard – Step 3 of 3 window select the first column in the ‘Data Preview’ section and set the ‘Column data format’ to ‘Text’. Repeat this step for the second column. This ensures that Excel treats the two TOID columns as text rather than numbers so doesn’t strip off the leading zero’s from any of the values (which are needed when joining the data to the building features in MasterMap later on), show image.
- Press Finish to complete the process, after which your data in Excel should look like the image below with the TOID values in the first column all 16 characters long and including three leading zero characters where necessary:
- AutoCAD Map 3D requires a ‘named range’ of cells to connect to. To create this highlight/select all cells that contain data in the workbook and using the ‘Name Box’ give this selection of cells a name. In the screen grab below we have called the selection ‘BuildingHeightValues’ (note your name cannot include spaces):
- Save your file as an .xslx file.
- The next step is to use the Windows ODBC Data Source Administrator to create a connection that points to this .xlsx file. Open the ODBC Data Source Administrator, the easiest way of doing this is to use the Windows search tool to search for ‘ODBC Data Source’.
- On the ‘User DSN’ tab press the ‘Add…’ button to create a new ODBC connection:
- Select ‘Microsoft Excel Driver’ and press the Finish button.
- Give your connection a name in the ‘Data Source Name’ field, and using the ‘Select Workbook…’ button browse and select the .xlsx file created above.
- Press OK and the newly created User DSN will be listed:
- Press OK to close the ODBC Data Source Administrator.
Preparing MasterMap Topography Layer GML data for use
- Open AutoCAD Map 3D.
- At the command prompt type: MAPIMPORT, or select ‘Map Import’ from the Insert menu.
- Browse to the .gz file downloaded from Digimap, ensure the ‘Files of type’ drop-down is set to ‘OS (GB) Mastermap (*.gml, *.xml, *.gz)’.
- Import just the TopographicArea layer by deselecting all other layers in the import dialog.
- Click on the word <None> in the Data Column for the TopographicArea layer.
- In the Attribute Data window select ‘Create object data’ and press OK.
- Select ‘Import polygons as closed polylines’ and press OK.
- The data will be imported in to your current map window. Note you may need to select View > Extents to see the data.
- The data needs to be converted to an .sdf file to allow the Building Height Attribute data to be joined to it.
- Connect to the .sdf file just created:
You have now added MasterMap buildings to your current map window, the next step is to connect to the Building Height Attribute (Excel spreadsheet) and join it to the building features in MasterMap.
Joining Building Height Attribute to buildings in MasterMap
- Connect to the BHA spreadsheet using the ODBC connection:
- In the Task Pane select Data > Connect to Data…
- Select ‘Add ODBC Connection’
- Give your connection a name and select the Data Source Name created above using the ‘…’ button next to the ‘Source’ field.
- Press the ‘Test Connection’ button.
- The table in the bottom half of the window will display all named ranges in your spreadsheet, we called our named range ‘BuildingHeightValues’. Before you can select this range for use in AutoCAD Map 3D you need to select a column to use as the ‘Identify Property’. To do this click on the text that says ‘<Click to select>’.
- In the drop-down that appears put a tick in the box next to the value ‘os_topo_toid_digimap’.
- Now you can tick the box next to the named range in the spreadsheet and press the ‘Connect’ button.
- The connection details will be displayed.
- The Data Connection window can now be closed.
- In the Task Pane right click on the MasterMap data and select ‘Create a Join…’
- In the ‘Create a Join’ window:
- select the building height data (in the Excel spreadsheet) as the ‘Table (or feature class) to join to’;
- select ‘TOID’ in the left hand drop-down menu;
- select ‘os_topo_toid_digimap’ in the right hand drop-down menu;
- select ‘Keep only left-side records with a match’ in the ‘Type of Join’ section;
- press ‘OK’ to create the join.
- To verify that the Join has worked, open the data table for the MasterMap data, this is done in the Task Pane by selecting the MasterMap data then pressing the ‘Table’ button. The table will be displayed, scroll to the right to see the joined building height values:
- The final step is to export the joined data as a new .sdf file which we can then visualise in 3D in InfraWorks. This is done by either right clicking on the MasterMap layer in the Task Pane and selecting ‘Export Layer Data to SDF…’ or by using the ‘Export to SDF’ function on the ‘Vector Layer’ ribbon in the ‘Save’ group.
Visualising the data in 3D using Autodesk InfraWorks
So far we have downloaded OS MasterMapÂ® Topography Layer and BHA data for the same area and joined the two together to create a new dataset containing just the building features which now include the various height attributes published by OS. We also downloaded additional data to use as a backdrop draped over the DTM surface, in this example we will use OS MasterMapÂ® 1:2,000 Raster, but OS VectorMapÂ® Local Raster or OS 1:25,000 Scale Colour Raster would also be suitable depending on the scale of your study area.
Visualising the data in 3D is achieved using Autodesk’s InfraWorks product . The steps below describe how to use the application to create a 3D model:
- Open InfraWorks and create a new model.
- Specify a location to save the model and give it a name:
- Click and drag the OS Terrain 50 DTM in to InfraWorks; the file to drag is the one with the .asc extension.
- In the Data Source Configuration window, ensure the Type is set to ‘Terrain’ and Coordinate System is set to ‘BritishNatGrid’:
- Press the ‘Close & Refresh’ button; the DTM should be displayed:
- Click and drag the final .sdf file created in the final step of the previous section which contains the heighted building data (i.e. the .sdf file created after joining the MasterMap buildings to the Building Height Attribute data spreadsheet).
- In the Data Source Configuration window, set the ‘Type’ drop-down to ‘Buildings’ and select a suitable ‘Roof Height’ attribute using the drop-down on the Common tab. As with previous blogs we have used the RelH2 attribute as we found this gave the best overall representation of building heights relative to each other:
- On the ‘Geo Location’ tab select ‘BritishNatGrid’ as the coordinate system:
- On the Source tab select ‘Drape’ from the drop-down under the ‘Draping Options’:
- Press the ‘Close & Refresh’ button, the buildings should now be displayed on top of the DTM, you may need to pan or zoom to view the data:
- To give some more context to the visualisation you can drape additional raster layers on top of the DTM such as OS MasterMapÂ® 1:2,000 Raster. This is done by selecting all the raster files and dragging them in to the InfraWorks window.
- In the Data Source Configuration window ensure ‘Type’ is set to ‘Ground Imagery’, and one the ‘Geo Location’ tab select the ‘BritishNatGrid’ Coordinate System:
- Select the ‘Close & Refresh’ button and the map data will be draped over the DTM surface:
The finished visualisation
The screen grab below shows the final visualisation centred on Biggar usingÂ OS MasterMapÂ® 1:2,000 Raster as the surface layer.