This tutorial reviews basic steps to use Blender and GIS addon for importing and processing basic Geospatial data
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Project_folder Add files via upload Oct 19, 2016
img course material Jul 22, 2017
sample Add files via upload Oct 14, 2016
.gitignore Draft1 Oct 14, 2016
Geospatial_studio.blend Add files via upload Oct 20, 2016
LICENSE Draft1 Oct 14, 2016
README.mc Published with https://stackedit.io/ Oct 16, 2016
README.md Published with https://stackedit.io/ Oct 20, 2016

README.md

3D Visualization of Geospatial Data with Blender

This tutorial intends to provide basic tips for importing and processing Geospatial data in Blender using BlenderGIS Addon.

Pre-requisites

  1. Blender Latest Build
  2. BlenderGIS Add-on
  3. Download Repository
  4. Laptop with Windows 7 or higher, Mac OS X or Linux
  5. GRASS GIS, ARCGIS or any GIS platform (optional).

0. Exporting Geospatial data in GRASS GIS (optional)

**Note: similar operations can be performed using ArcGIS. For comprehensive tutorial on importing different data-types (e.g., Lidar, vectors and rasters) using GRASS GIS and ARCGIS see Geospatial Modelling Module

####0. 1. Exporting Raster

  • Open GRASS GIS
  • Export rasters with Geotiff format containing the world file. For best compatibility, use float32 as datatype

Command Console >>>

r.out.gdal input=elev_cut@Dix_10_12 output=D:\Geospatial_studio\elevation.tif >format=GTiff type=Float32 createopt=TFW=YES

####0. 2. Exporting Vector

  • Export vector data as ESRI shapefiles (.shp) **Note: When exporting the shape files preserve attributes such as unique object identifier or spatial information such as elevation or height

Command Console >>>

v.out.ogr input=Buidlings@Dix_10_12 output=D:\Geospatial_studio\Buildings >format=ESRI_Shapefile


###1. Preparing Blender scene

####1. 1. Setup Blender GIS addon

  • Make sure that addon is properly installed
  • Open Blender and from file menu select user preferences (or use Alt + Ctrl + U ), and then select Add-ons tab
  • In the search tab on top left type 'gis' and make sure that in the Categories section All is selected.
  • You should be able to see multiple components of the Addon. Select to activate all components.
  • From the bottom of the preferences window click Save User Settings

####1. 2. Adding a new predefined coordinate reference system (CRS)

  • Before setting up the coordinate reference system of the Blender scene and configuring the scene projection, you should know the Coordinate Reference System (CRS) and the Spatial Reference Identifier (SRID) of your project. In GRASS GIS, CRS information can be retrieved using v.info or r.info functions . You can get the SRID from http://epsg.io/ or spatial reference website using your CRS. The example datasets in this exercise uses a NAD83(HARN)/North Carolina CRS (SSRID EPSG: 3358)

  • In BlenderGIS add-on section (in preferences windows), select to expand the 3D View: BlenderGIS

  • In the preferences section find Spatial Reference system and click on the + Add button

  • In the add window put 'EPSG: 3358' for definition and 'NAD83(HARN)/North Carolina' for Description. Then select Save to addon preferences

**Note: For a more comprehensive instruction on Georefencing management visit BlenderGIS addon wiki page

####1. 3. Opening the blender file and setting the Coordinate system

  • From the file menu, select open , browse to find the downloaded 'Geospatial_studio' folder and open the 'studio.blend' file
  • From the 3D view toolbar (on the left side of the screen) , find GIS panel If you cannot find the GIS tab, then check if the add-on is properly installed and activated in blender preferences (step 1.1. )
  • In the second section of the panel , Geoscene, click on the Gear shaped icon . You should be able to find and select the 'NAD83(HARN)/North Carolina' preset. After selecting it click on the icon to set it as scene coordinate system.

###2. Importing Geospatial datasets ####2. 1. rasters Rasters can be imported and used in different ways. You can import them As DEM to use it as a 3D surface or as_Raw DEM_ to be triangulated or skinned inside Blender. You can select On Mesh to drape them as a texture on your 3D meshes. In this example, we import the lidar elevation dataset as a 3D mesh using As DEM method.

  • From file __ menu select__import and find Georeferenced raster
  • On the bottom left side of the window find Mode and select As DEM
  • For Subdivision select Mesh and make sure that CRS is set to NAD83(HARN)/North carolina.
  • Browse to the 'Geospatial Studio' folder and select 'DEM.tif'
  • If all the steps are followed correctly, you should be able to see the terrain in 3D view window
  • In 3D view Right-click on the DEM object to select it , push Alt+c and select Mesh from Curve .Make sure the mouse cursor is in the 3D view area. This is step converts the imported raster to Mesh object type to allow further modification

*Trouble shooting: When importing your own raster data, you might encounter situations where the DEM is imported as a flat surface. Make sure that 1) you selected the As DEM method 2) the raster resolution is not very low, 3) the data-type is float32, and 4) the coordinate system of the raster is matching the Blender Scenes' coordinate system. For more detailed instructions and troubleshooting read georeference raster import wiki .

Python Console >>>

bpy.ops.importgis.georaster(filepath="D:\Geospatial_studio\DEM.tif",importMode="DEM",subdivision="mesh",rastCRS="EPSG:3358")
bpy.ops.object.convert(target='MESH')

####2.1. Vectors **Note: When importing a shapefile it's necessary to specify the projection of the file Blender Addon reads into the attribute table of the shapefiles. This is helpful when you want to dismantle the shape files into discrete and uniquely named 3D objects. Also, the z coordinate or elevation attributes of the vectored can be used to extrude or define the hight of the 3D objects. In this tutorial, we use two different shape-files to entertain these attributes. First, we will import the building shape file , and will assign the height and the name attribute to the corresponding 3D objects. Then, we will import the Lidar pointclouds for high vegetation (trees) using the Z coordinate attribute.

Buildings

  • From file __ menu select__import and find Shapefile(.shp).
  • Browse to 'Geospatial_studio\shp' , select 'Building.shp' and click on import SHP on top right of the window. You should be able to see the import SHP parameters dialog on the left side of the screen.
  • Select Elevation from the field and from the filed drop-down menu select elevation
  • Select Extrusion from the field and from the filed drop-down menu select height
  • Select separate objects and object name from the field , and from the filed drop-down menu select building
  • The CRS should be already set. If not, select NAD83(HARN)/North Carolina and click OK
  • You should be able to see and select buildings as separate objects on the terrain, right click on each building object and check its name in the outliner panel (top right)

Python Console >>>

bpy.ops.importgis.shapefile(filepath="D:/Geospatial_studio/shp/building.shp",fieldElevName="elevation",fieldExtrudeName="height",fieldObjName='Building',separateObjects=True,shpCRS='epsg:3358')

Lidar point clouds

  • From file __ menu select__import and find Shapefile(.shp)
  • Browse to 'Geospatial_studio\shp' , select 'Lidar_highveg.shp' and click on import SHP
  • In the import SHP parameters dialog, make sure that the correct CRS is indicated and click OK

###3. Materials and Texture In this section we will drape orthophoto as a texture on the terrain. You can apply textures to the 3D surfaces in blender using complex mapping methods (e.g. height mapping, bump mapping, normal mapping, displacement mapping, reflection mapping, specular mapping, mipmaps, occlusion mapping). However, texture mapping is beyond the scope of this tutorial. If you are interested to learn more about texture mapping and materials in blender, Blender wikibooks is a good place to start.

  • From the top header select Cycles Render as your rendering engine.
    Note: Cycles is Blender’s ray-trace based production render engine. Discover more about cycles here
  • You can design workflows related to materials and textures in Node editor environment. Change the bottom editor panel to node editor. This can be done by simply changing the Editor Type selector button which is located at the left side of a header. Every area in Blender may contain any type of editor and it is also possible to open the same type multiple times. Discover more about node editor here
  • From 3D view header( bottom of the window) , find Viewport shading button and select Material
  • In 3D view, right click on the DEM to select the object
  • From the properties panel(you can find it below the outliner), goto Material and from Material browser select 'Ortho_texture'. Now you should be able to see the material workflow in node editor
  • On the left node , image Texture , find open image , and browse to the geospatial folder to 'select the Ortho.png'. You should be able to see the texture draped on the terrain

4. Populating Trees

In this step, we populate evergreen and deciduous trees on the terrain surface. There are many ways to do that in Blender. The most efficient method is _Particle Systems Modifier which scatters a predefined duplicates of an objects (particle) on the surface of another object ( Emitter). The pattern through which the particles are scattered can be defined using Vertex groups,using which we simply define the vertices of the surface that should get populated. In this tutorial, the particle systems are already setup and ready to assign to the elevation surface , we will only go through creating the vertex groups. You can setup your own particle system using the instructions provided here.

####4.1. Assigning vertex group

  • Right click on the terrain to select 'elevation' object.
  • In properties panel find Data . In data panel expand Vertex Groups and click on + button to add new vertex groups. Add two new vertex groups and name them 'Evergreen' and 'Deciduous', respectively. Click on Evergreen to set as active vertex group.
  • Now we select our desired vertices using __weight paint __ method
  • In the bottom header of the 3D view, find and change the Object interaction mode to weight paint (hotkey ctrl+Tab)
  • From the left toolbar change the weight to 1.00
  • Using the tree point clouds as spatial reference, paint over the surface to delineate the dense forested patches. Use ( ctrl+Tab) to toggle back and forth between object mode and _weight paint mode to see the ortho photo and get idea about the exact location of the patches. switch to object mode after painting is finished.
  • Now select 'Deciduous' as active vertex group and repeat the process for the rest of the trees in the scene

Python Console >>>

######Clear existing vertex groups and add two new groups bpy.data.objects['elevation'].vertex_groups.clear() bpy.data.objects['elevation'].vertex_groups.new(name='Evergreen') bpy.data.objects['elevation'].vertex_groups.new(name='Deciduous') bpy.data.objects['elevation'].vertex_groups.active_index=0 ######Toggle weight paint mode and assign weight bpy.ops.paint.weight_paint_toggle() bpy.context.scene.tool_settings.unified_paint_settings.weight = 1

####4.1. Setup particle systems

  • In the properties panel select Modifiers tab. Then, click on the Add Modifier drop down menu and select particle system.
  • Now expand the modifier (using the button on the right side) to see the modifier parameters. Browse Setting to find and select 'Evergreen'
  • Expand Render tab to and select Object . Browse Dupli Object option to find "Evergreen". Dupli object is the particle which would be populated on the landscape.
  • Scroll down to find the Vertex Groups tab and expand it to see the parameters. In Density field find and select 'evergreen'. Now should be able to see the trees populated in the painted areas
  • Repeat the same procedure for the 'Deciduous' vertex group , but this time select 'Deciduous' both in particle setting and Vertex group parameters. Also, for the Dupli object select "Deciduous"
  • The dimension and number of particle objects can be adjusted using Emission parameter

Python Console >>>

DEM=bpy.data.objects['DEM']
bpy.ops.object.particle_system_add()
psys1 = DEM.particle_systems[-1]
pset1 = psys1.settings
pset1.name = 'Evergreen'
pset1.use_dead=True
pset1.frame_start = 1
pset1.frame_end = 1
pset1.lifetime = 50
pset1.lifetime_random = 0.0
pset1.emit_from = 'FACE'
pset1.count=600
pset1.use_render_emitter = True
pset1.emit_from="FACE"
pset1.use_emit_random=True
pset1.userjit=70
pset1.use_modifier_stack=True
pset1.use_rotations=True
pset1.render_type='OBJECT'
pset1.dupli_object = bpy.data.objects["Evergreen"]
pset1.use_rotation_dupli=True
pset1.particle_size=.3
pset1.size_random=.3
pset1.rotation_mode='OB_Y'
pset1.type = 'HAIR'
psys1.vertex_group_density='Deciduous'

5. Rendering

There two different ways to render scene in Cycles render engine. You can activate Real time-rendering that is useful for quick previews or GPU rendering for final output. Note that the GPU rendering is by default setup to render only active camera.

  • In 3D_view bottom header find Shader option and select Rendered . Interact with the 3D model to see how it is rendered on the-fly.
  • Set one of the windows (scripting or node editor) to camera view. This can be done by selecting 3D view from bottom header of the window. Then select the desired camera by right-clicking on the camera object in 3D view or selecting the object name (e.g, camera) in outliner. Then, set the 3D view to camera using NUM0.
  • For final rendering push F12 after selecting the desired camera. For changing the render output and parameters, use the Render tab in the Properties panel.

Python Console >>>

######Change the 3D view shader to rendered bpy.context.space_data.viewport_shade = 'RENDERED'

######Change the active camera to object 'Camera' and set 3D view window to camera .
**Note: can be only executed from text editor. cameraObj=bpy.data.objects['Camera']
bpy.context.scene.objects.active = cameraObj
bpy.ops.view3d.object_as_camera() ######Render directly to the file path bpy.context.scene.render.filepath = "D:\\Geospatial_studio\\Render\\t_"
bpy.ops.render.render() ######Render in background using windows run command
../blender-2.77a-windows32/blender.exe d:/test/test.blend --render-output d:/test/t_ --engine CYCLES --render-format PNG --use-extension 1 --render-frame 1

6. Acknowledgment

This work is built upon great contributions and support of Blender team, Blender GIS addon developers (domlysz/BlenderGIS) , Center for Geospatial Analytics and Vaclav Petras.