Further Adventures with 3D GIS

Originally Posted in xyHt on 19th November, the original article can be read here

Last year I posted about this awesome plugin called “QGIS2Threejs” [here] and how it was possible to quickly render 3D visualisations for free using the open source GIS, QGIS. At the time I fudged some wind turbines as it was impossible to import models, furthermore I avoided too much detail as any imagery would look poor when zoomed in. In short, it was good but was not an alternative to ESRIs’ CityEngine or a model you could build in Blender.

A year and a half later, it’s a different story [demo here]

OS3DThe wind turbine is a model I built in Sketchup and exported as a Collada file, the trees are created from Ordnance Surveys Open Map data (based on the woodland polygon), this is something which I could provide to a client to show how their issues interact with some confidence.

OS3D2Note in the above picture how the trees have a slight randomness, I really liked the way this came out using the QGIS vector tools.

Below is a breakdown of the data and steps to reproduce it.

Software Required:

  • QGIS 2.12
  • Sketchup or Blender

Data Required:

  • OS OpenMap
  • Environment Agency Lidar DTM & DSM

Steps to reproduce:

  1. Open QGIS and import the OS data, style either with the QLR styles provided by Ordnance Survey or Ross McDonald personally, I created my own based on the Ordnance Survey style as it is instantly recognisable.
  2. Using QGIS, bring in the DSM and intersect the height with the buildings to add a z value to the buildings. I found that adding this height as a field was good for checking later on. Make sure that you use a mean height for the buildings so that you dont end up with strange shaped roofs.
  3. Using only the woodland layer of the OS OpenMap data convert to random points. Remember that your “average” tree is about 5m high and you want about 2m seperation (radius). Regular PointsThe regular points tool can be found in the ‘Vector’ tab under ‘research tools’ – Don’t be tempted to use the ‘random points’ tool as it is quite tricky to set the density right for the varying polygon sizes. There is a tick box on the regular points so that some ‘randomness’ is generated.
  4. Create a new point shapefile, this will be used to provide a location for you turbine/model. Obviously, put the point(s) where you want your objects to be.
  5. Create or download your 3D objects. For this part, I made the turbine with Sketchup to the correct dimensions. The Sketchup 3D warehouse has a plethora of 3D models, cars, planes, a Back to the Future DeLorean….they can all be exported in Collada format from Sketchup, just ensure they are located correctly within the space – the model will render in reference to the point file you create, meaning that the point will be used as the models 0.0. You can also build models in Blender, AutoCAD or Threejs – As long as it is in Collada format, QGIS2Threejs can read it.
  6. Double up your trees! You need to have a trunk and a treetop, therefore, bring in the tree data again…..
  7. Open QGIS2Threejs, it should be under the ‘Web’ tab in QGIS, if you don’t have it there, go and add it as a plugin.
  8. Okay, now for the fun part. Whatever is currently shown in the dataframe, is what will be used as the imge overlaid on the terrain…so tidy it up and consider that the buildings, trees & model will be sat on top (Might be worth turning them off in the layers) QGIS2ThreejsSet your DEM to reference the DTM
  9. Here is where having 2 sets of trees comes in useful – set your first set of trees as cylinders (as above). Set a radius of around 0.5 (assuming you are using a metric projection). Then height to around 5-7m, I found that although the Institute of Architects recommend 7m, 6m worked well.
  10. For the second set of trees, set the oject type to sphere, radius of 2m and height the same as the trunk. DON’T forget to set the colour to green & the trunk to brown!
  11. Set the buildings to the ‘Extruded’ object type and set the Height (NOT THE Z COORDINATE) to the height field you generated, you can also use the object geometry, though I find the field method more reliable.
  12. Set a file/folder location and then sit back and enjoy!

But it’s no ESRI CityEngine…

True, this is not CityEngine, nor would it ever need to be. It is a FREE plugin for generating geographically correct 3D models…but what if I told you that you could add buildings with shape? There are companies like CyberCity3D who sell 3D buildings and cities, therefore you can bring in more accurate buildings….

This is only the beginning for QGIS2Threejs, it is built on the rather amazing Threejs. Looking under the hood of the code, it is quite easy to add fog, shadows and adjust the angle of light. It wouldn’t take much for someone with a little more know-how in javascript to add a control for light dependent on time of day.

One thing is for sure, this is a great little plugin, with a lot of potential.

Nick D