TUTORIAL BlenderGIS - How to drape ortho-photos onto a DEM/DSM

Discussion in 'Tracks' started by barf, Jan 26, 2019.

  1. barf

    barf Member

    Joined:
    Aug 6, 2018
    Messages:
    77
    Likes Received:
    111
    BlenderGIS is a blender plugin designed to bridge the gap between Blender and geographic data.

    [​IMG]
    [​IMG]
    [​IMG]

    This plugin is useful for track building because it enables scene geo-referencing using WGS84 or other co-ordinate reference systems (CRS), importing OpenStreetMap data, and importing geo-referenced rasters containing ortho-photography, or digital elevation/terrain and surface models.

    This tutorial will cover importing (GeoTIFF) LiDAR DEM/DSM products, and satellite terrain and aerial photos directly into blender, while accurately preserving the scale and units. Merging and extracting the geo-rasters used here is a different subject so I might make a short tutorial on QGIS also.

    Installation
    To install the plugin download the latest release and extract the zip's contents into: %userprofile%\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\
    (assuming your blender version is 2.79 on Windows).

    Enable the plugin in User Preferences.

    Note: installing GDAL into the Python environment packaged with Blender on Windows is beyond the scope of this tutorial, I found using BlenderGIS on Linux to be easier because it uses the system Python environment. Some features may be unavailable on Windows without GDAL. YMMV.

    Geo-referencing
    1. Click the GIS tab while in object mode
    2. Click the cog to select a 'CRS'. WGS84 is probably the correct choice for most projects, unless you have access to GIS data from an area with it's own map projection and co-ordinate system, ie; Antarctica uses EPSG:3031.
    3. Click the plus + to add an Origin
    4. Click 'Geo' and enter the longitude and latitude you want to be the origin point of your project. Decide on a scene origin that makes sense for your project. Roughly in the center of it, and round the less significant digits off. (If using a localised projection/CRS, click 'proj' and use those units instead)
    In theory, when we import any geo-spatial data we must harmonise into one CRS: the native Cartesian system in meters that AC uses for it's physics and visuals. BlenderGIS does this for us.

    Also, by working with a geospatial co-ordinate system in blender instead of a pure Cartesian system, it is possible to preserve the curvature of the surface of the earth in our scene. It's the little things that count ;)

    Raster Import
    Elevation/Terrain Model (DEM/DTM/DSM) import
    1. Click the Import Georaster button.
    2. Navigate to the raster file.
    3. Select the import mode "Raw DEM" (use this mode for DSMs also, it's just where the vertex's Z value will end up)
    4. Select the "Build faces" checkbox.
    5. If the file you're importing is a different CRS to the scene CRS, select "Specify raster CRS" and choose the input file's CRS.
    6. The scene geo-referencing items should automatically be set.
    7. Click Import georaster.
      [​IMG]
      [​IMG]
    Ortho-photo import
    1. Click the Import Georaster button.
    2. Navigate to the raster file.
    3. Select the import mode "On mesh" to UV-map the raster onto an existing mesh.
    4. Select the object to apply the raster to. (Ie; the DEM/DSM you imported previously)
    5. If the file you're importing is a different CRS to the scene CRS, select "Specify raster CRS" and choose the input file's CRS.
    6. The scene geo-referencing items should automatically be set.
    7. Click Import georaster.
      [​IMG]
      [​IMG]
    Post-import
    To optimise the mesh, it is a good idea 'dissolve' redundant vertices. Because raster data is a grid array, there will probably be unnecessary vertices, especially in flat and open areas. Use the 'Limited Dissolve' feature in vertex edit mode, after selecting all vertices. Set the threshold for a good trade-off, lower angles will preserve more geometry.

    Example Data
    The elevation and aerial imagery here is sourced from the LINZ Data Service and licensed by Environment Canterbury Regional Council, for re-use under the Creative Commons Attribution 4.0 International licence.

    Download
     
    Last edited: Jan 27, 2019
    Patrice COte, Won, AccAkut and 3 others like this.
  2. luchian

    luchian Administrator Staff Member Pilot RLR

    Joined:
    Jun 3, 2014
    Messages:
    2,876
    Likes Received:
    1,375
    Very cool, thank you for taking the time to write how-to :).

    It is actually more than just "inspirational", it's a useful tool for track creation, so I will move it into the Tracks section.
     
  3. Pixelchaser

    Pixelchaser Well-Known Member

    Joined:
    Jan 4, 2015
    Messages:
    1,538
    Likes Received:
    1,046
    yeah, that's fantastic. especially what seems to be some access to the roads api from google. that's how to give RTB the middle finger ! :lol:
     
  4. barf

    barf Member

    Joined:
    Aug 6, 2018
    Messages:
    77
    Likes Received:
    111
    I do wonder why RTB enjoys so much popularity when free and open-source tools exist, I guess it is easier to use? but if I had that kind of money I would buy parts for my Toyota anyway :ROFLMAO: RTB costs more than the entry fee to get out on my local track.

    BTW if the above looks easy, it's because it is! Most of the work to get that result is in QGIS, so I'll put up a tutorial on how I made those GeoTIFFs.

    My pipeline is simply:
    QGIS -> blender (kn5 exporter plugin) -> AC

    I can't seem to use ksEditor, my textures always make it explode :(
     
  5. Pixelchaser

    Pixelchaser Well-Known Member

    Joined:
    Jan 4, 2015
    Messages:
    1,538
    Likes Received:
    1,046
    its quite enjoyable to use tbh even in its perspective orientation. I know with the amount of manual vert placing I do id rather do it in rtb initially.

    the quality versus crap ratio would be better without RTB for sure apart from my tracks ofcourse hehe. . haha it should be renamed "flightsim terrain builder" for even more popularity. ;) :lol: but lets not throw that idea out for brendon.

    recently released on steam was "bobs" track builder. imagine that ! Brendon can go swivel on a Californian desert cactus for all I care. if I met him in a pub. id punch him then apologise and buy him a pint)( pending getting kicked out :lol:)
     
  6. ebrich

    ebrich New Member

    Joined:
    Apr 22, 2017
    Messages:
    4
    Likes Received:
    2
    If some features, are or may not be available on windows (GDAL) is this going to work on Win 10? It would be great to get it working.
     
  7. barf

    barf Member

    Joined:
    Aug 6, 2018
    Messages:
    77
    Likes Received:
    111
    Compiling anything on Windows is a PITA. You will need Visual Studio installed and the Visual C++ SDK.

    To get the GDAL module into the blender-python distribution install pip into it first, then use pip to download and install GDAL.
    1. Download get-pip.py to somewhere
    2. Open a command prompt as administrator
    3. cd to C:\Program Files\Blender Foundation\Blender\2.79\python\bin (or wherever your blender python executable is)
    4. Run> python.exe \path\to\get-pip.py
    5. Run> python.exe -m pip install gdal
    but I only got as far as "extensions/gdal_wrap.cpp(3173): fatal error C1083: Cannot open include file: 'cpl_port.h': No such file or directory" so that needs fixing, building the git version instead of the pip package might help, seems like there's a missing C header in it on Windows.

    There's precompiled python 'wheels' for GDAL but not for python 3.5 which is the bundled version in blender:
    https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal
     
    luchian likes this.
  8. ebrich

    ebrich New Member

    Joined:
    Apr 22, 2017
    Messages:
    4
    Likes Received:
    2
    Thanks for that.

    I think I'll have a shot at getting it running on a virtual Linux, at least there will be a little bit of light at the end of the tunnel.

    Your second GIF (EXPORT GOOGLE Sat) wouldn't be Navacelles by any chance?
     
  9. barf

    barf Member

    Joined:
    Aug 6, 2018
    Messages:
    77
    Likes Received:
    111
    The GIF is just from the blenderGIS homepage, it might be :)

    Found a relevant video tutorial on geo-referencing rasters with QGIS:
     
    Prototype, ebrich and luchian like this.
  10. ebrich

    ebrich New Member

    Joined:
    Apr 22, 2017
    Messages:
    4
    Likes Received:
    2
    When I select the BlenderGIS-Blender28 in the addon user pref. window I get an error ending with "DLL load failed - this is not a valid win 32 application". Does that mean that blender 28 has to be a 32 bit and not a 64 bit?

    Otherwise, thanks to the above video and a couple of other tutorials, so far, I have a tif a contour and shp file ready to attack blender 2.79.
     
    barf likes this.
  11. barf

    barf Member

    Joined:
    Aug 6, 2018
    Messages:
    77
    Likes Received:
    111
    That error might relate to Python itself being unable to load (python35.dll in 2.79). Can you reproduce it if you press shift-F4 in blender to get the python console?

    blenderGIS is Python, I think it should work on both 32 and 64 bit :confused:

    FWIW I'm using 64-bit Blender 2.79b - it shows the following Python interpreter banner when I press shift-F4:
    PYTHON INTERACTIVE CONSOLE 3.5.3 (default, May 20 2017, 19:10:40) [MSC v.1800 64 bit (AMD64)]
     
    ebrich likes this.
  12. ebrich

    ebrich New Member

    Joined:
    Apr 22, 2017
    Messages:
    4
    Likes Received:
    2
    The python console gives me the same - "PYTHON INTERACTIVE CONSOLE 3.5.3 (default, May 20 2017, 19:10:40) [MSC v.1800 64 bit (AMD64)] ".

    At the moment I'll stick with Win 10 Blender 2.79b. and go through the documentation again as I have a shp file with the correct attributes taken from a Nasa hgt file.

    As it says "Following this paradigm BlenderGIS always make the assumption you have a good knowledge on what you are trying to import, if it's not the case please go to step 1."!!

    I'll get there in the end, and if I don't get there, it means it's not the end.
     
    barf likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice