Why a 3D Topographic Model?
I’ve been asked to produce a walk-through animation of a reconstructed archaeological site that shows the landscape setting of important buildings, and how these buildings constrained the movement of people. Reconstructing the buildings is pretty simple, with lots of reference material available. However, the 3D topographical model of the landscape is much trickier, made worse by not having any digital elevation data, only paper maps with contours.
Drawing contours with height attributes is easy in ArcGIS, but when I was asked to create an animation, I had no idea how to get the GIS shapefile data into my 3d software for animating. I figured there must be a way, and sure enough, ArcGIS has all the tools for converting and exporting a shapefile that can then be opened in pretty much any 3d software package.
What we’ll be doing
For this exercise I will be using ArcGIS, Excel and MeshLab. The 3d mesh that we’ll create in MeshLab will be exported in a file format that can be imported straight into Autodesk’s 3dsMax, where it will be used to create the final animation.
By the end of this you’ll be able to:
- Convert a vector contour layer to a raster DEM layer using the vector layer’s height field
- Convert a raster DEM to a point cloud in ASCII text file format
- Import an ASCII text point cloud file into MeshLab and create a mesh that can be used in most 3d software packages
Drawing in ArcGIS is a pretty basic skill that I won’t go into here, but I will say that your contour lines should be drawn as polylines, not polygons. As the end result will be a 3d model from 2d map data, make sure you have added a height field (z, height, or whatever you want to call it) to your contour layer’s attribute table.
Now, spend the next however many hours of your life robotically drawing contour lines. This is going to be unbelievably tedious, so put some music on and get comfortable. Remember, after you finish drawing each contour line, add its height value to the height field in the layer’s attribute table. Also, save your edits and map regularly.
Now that you have traced all the contours on your map and added each line’s height value to the height field in the layer’s attribute table, you’re ready to crack open your ArcToolbox and dust off two rarely (for me!) used tools: 3D analyst Tools > Raster Interpolation > Topo to Raster and Spatial Analyst > Extraction > Sample. These two tools have very few parameters that need to change and are pretty much ‘wash and go’.
Convert a contour polyline to raster DEM
- ArcToolbox > 3D analyst Tools > Raster Interpolation > Topo to Raster
- Select you contour layer as the input feature
- Under ‘Field’, select the field that contains your height data
- Enter a name and save location for your raster under ‘Output surface raster’
- Leave everything else as default
- Click OK
Isn’t that a beautiful DEM? If all you’re after is a DEM for your map, have a play with the symbology settings until you’re happy, then you’re done. However, this is only a step along the way to creating a 3d model, so onto the next step.
Convert a raster DEM to ASCII text
- ArcToolbox > Spatial Analyst > Extraction > Sample
- Select your DEM from the ‘Input rasters’ dropdown
- Select your DEM as ‘Input location raster or point features’
- Select save location and file name, adding .dbf to file name
- Set resampling technique to ‘Bilinear’
- Under Environments > Processing Extent, set input raster as ‘Snap Raster’
- Click OK
Now you should have a .dbf and an .xml file in your chosen save location. We’re only interested in the .dbf file, but don’t delete the .xml file, as ArcGIS will be sad without it.
Editing the ASCII text file
The export to text we did in the last step will usually create extra columns and give our height column an unusual name, so now we need to do a little bit of editing in Excel.
- Open the dbf file in Excel
- Column ‘contour_ra’ is essentially the same as column ‘contour__1’ only rounded. Rename ‘contour_ra’ as ‘z’ and delete column D
- Reorder the columns to x, y, z
- Save as MS DOS .txt
Creating a mesh from point data in MeshLab
I wouldn’t normally use MeshLab for this step, preferring other point cloud tools, but MeshLab is free and available to everyone.
- Open up MeshLab and import the text file you created in the last step
- In the Open Options dialogue box, select the parameters for your file. Usually this just means changing ‘separator between’ to SPACE.
- You should see a point cloud that (hopefully!) resembles the surface of the map you spent all that time drawing.
- Hit CTRL + L to show the layers panel
- Right click the point layer and select ‘Duplicate Current Layer’
- Hide the original layer and change the duplicate layer display to points
- Go to Filters > Normals, Curvatures and Orientation > Compute normals for point sets
- Change ‘Neighbour num’ to 1000. Leave all other parameters at default
- Click Apply then Close
- Go to Filters > Point Set > Surface Reconstruction: Poisson
- Change ‘Octree Depth’ to 11
- Click Apply then Close
- This will create a new layer containing the new mesh
- Go to File > Export Mesh As… and choose a name and save location for your new mesh
That’s all there is to it. You’ve used ArcGIS to convert a vector contour layer to a raster DEM layer using the vector layer’s height field and converted that raster DEM to a point cloud in ASCII text file format. You’ve imported that point cloud into MeshLab to create a mesh that can be used in most 3d software packages.
In this example I exported to .ply format, but MeshLab will export to many other file types, so that whatever the final destination for the 3d model, there should be a compatible option for you.
I hope you found this pretty easy to follow, and if you have any questions, drop them in the comments box below.