You are on page 1of 3

Dismiss

27x How to install GDAL


domlysz edited this page on Jan 5, 2019on Jan 5, 2019
·
2 revisions

GDAL is a popular and powerful geospatial data processing library. GDAL is available as a set of
commandline utilities (ready to use binaries files). The developer oriented library is available as a C/C++
API. Bindings in other languages, including Python, are also available.

GDAL is an optional dependency, most of the functionalities of BlenderGIS are available without it. If the
addon does not works as expected, installing GDAL will not solve the issue. GDAL can be useful for
advanced users who need more support for GIS specific fomats and reprojection tasks directly in Blender.
However, if you want to deal with heterogeneous data formats, projections or extents, the most
straightforward strategy is to preprocess your data with QGIS before trying the import into Blender. QGIS
is a powerful open source desktop GIS software, this is an essential tool for working with BlenderGIS
because it will help prepare the data for a smooth import. Futhermore, installing GDAL with Blender can
be really tricky because Blender bundle it's how Python installation.
Windows
On Windows, the most easiest way to install GDAL Python Binding is to use the packages build by
Christoph Gohlke and available here. Choose the package that match the version of Python bundle with
Blender, you can determine it by opening the Python console in Blender. In the following screenshoot this
is Python 3.5.3, the corresponding package is named GDAL-2.2.4-cp35-cp35m-win_amd64.whl.

The *.whl package file contains a stand alone GDAL installation including all needed files (binaries,
libraries, Python binding...), so you don't need to install any other file.

Blender bundle it's own Python executable at blender_install_folder\2.7x\python\bin\python.exe ,


after downloading the whl file, put it in this directory and then open a new Windows terminal from this
folder. To do this, in the file explorer right click while maintaining shift key and choose open command
window here.

You need pip utility to install *.whl package files, so the first step is to install pip with the following
command :

python.exe -m ensurepip
Then you can install the wheel file:

python.exe -m pip install GDAL-2.2.4-cp35-cp35m-win_amd64.whl

GDAL will be installed into blender_install_folder\2.7x\python\lib\site-packages\osgeo

GDAL Python binding needs Numpy to correctly working. Numpy is already included with Blender Python
installation, but most of time this version does not match the one used to compile GDAL module. So, to
ensure the best compatibility it's more careful to also install Christoph Gohlke's Numpy wheel package.

After dowloading the file, install it in the same way as previously :

python.exe -m pip install numpy-1.14.5+mkl-cp35-cp35m-win_amd64.whl

To finalize the installation, it's necessary to define a new Windows environment variable named
GDAL_DATA and pointing the following directory : blender_install_folder\2.7x\python\lib\site-
packages\osgeo\data\gdal

To test the install open Blender Python console and type:

from osgeo import gdal

from osgeo import gdalnumeric

These statements should not return error.

For testing if GDAL_DATA environment variable is correctly setup type :

from osgeo import osr

osr.SpatialReference().ImportFromProj4('+init=epsg:3857')

The second statement must return zero, a value >0 refers to an error code.

You might also like