Installing GDAL
This document describes the GDAL 1.3.2 compilation and installation process for Windows.
Quick Installation
If you do not wish to undergo the messy process of compiling GDAL from source, we provide a pre-compiled installation binary:
http://www.urbansim.org/download/files/third-party/gdal-python-13.win32-py2.4.exe
Simply follow the instructions provided in the executable and skip to the Final Steps section of this page. For users who wish to compile and install GDAL from source, instructions for this process are provided in the next section.
Compiling and Installing GDAL 1.3.2 from Souce
This section outlines the process we used to compile the Geospatial Data Abstraction Library (GDAL) and set up the Python bindings. The instructions in this section are for advanced users who wish to compile and install GDAL from source. These instructions assume Microsoft Visual Studio 7.
Download the GDAL 1.3.2 source (gdal132.zip) from http://www.gdal.org/dl/
Extract the archive into the location of your choice (such as the C:\).
Edit the nmake.opt file and un-comment the line 'HAVE_NUMPY=1'.
Open a command prompt and change directories to the location of the extracted files.
Locate and execute vcvars32.bat from your Visual Studio 7 installation.
Execute the following three commands:
nmake /f makefile.vc nmake /f makefile.vc install nmake /f makefile.vc devinstall
Copy gdal13.dll into the pymod directory.
Change to the pymod directory:
Create a file called setup.py:
from distutils.opus_core import setup, Extension
version = '13'
setup (name = "gdal-python", version = version,
description = "Geospatial Data Abstraction Library: Python Bindings",
packages = ['gdal'], package_dir = {'gdal': ''},
ext_modules = [Extension('gdal._gdal',
sources = ["gdal_wrap.c", "gdalnumeric.cpp", "numpydataset.cpp"],
include_dirs = ["..\\gcore", "..\\port", "..\\ogr", "..\\alg" ],
libraries = ["gdal_i"],
library_dirs = [".."]
),
],
data_files = [("", "gdal%s.dll" % version)]
)
Edit gdal_py.h, and place '#define HAVE_NUMPY' before the line that reads '#ifdef HAVE_NUMPY'.
Edit makefile.vc, and change EXTRAFLAGS to '-I$(PYDIR)/include -DHAVE_NUMPY'. Finally, execute the following two commands:
python setup.py build python setup.py install
This concludes the compilation and installation of GDAL from source section.
Final Steps
Move _gdal.pyd from your Python installation's Lib/site-packages/gdal folder into your Python installation's DLLs folder.
If it does not already exist, create a blank init.py file in your Python installation's Lib/site-packages/gdal folder.
Testing the installation
You have completed the installation of GDAL 1.3.2. To test your installation, run opus_core.opus_gdal. The output should resemble the following:
. ---------------------------------------------------------------------- Ran 1 test in 0.047s OK
If the output is similar to the above, then the GDAL Python bindings have been successfully installed.
