GDAL and GDAL2Tiles
GDAL (Geospatial Data Abstraction Layer) includes GDAL2Tiles that can generate map tiles for OpenLayers, Google Maps, Google Earth, and similar web maps. GDAL can be installed from OSGeo4W for Windows. We can find OSGeo4W at http://trac.osgeo.org/osgeo4w/. Unfortunately this only works for 32bit Windows as of now I am writing this article.
OSGeo4W is a package from Open Source Geospatial Foundation for Win32 environments. According to the OSGeo website,
OSGeo4W is a binary distribution of a broad set of open source geospatial software for Win32 environments (Windows XP, Vista, etc). OSGeo4W includes GDAL/OGR, GRASS, MapServer, OpenEV, uDig, QGIS as well as many other packages (about 150 as of fall 2009).
OSGeo4W Setup for 32bit Windows
Caution: Do not follow the instructions at http://trac.osgeo.org/osgeo4w/ or http://help.maptiler.org/betatest/ for GDAL2Tiles. Especially there is a specific instruction at http://help.maptiler.org/betatest/ that you should not follow. That instruction only worked for GDAL 1.6 beta. Here is a new instruction for installation of GDAL for using GDAL2Tiles.
- Download the OSGeo4W installer from here.
- Run the installer.
- Select Advanced install.
- Select Libs and select gdal and gdal-python in the Select packages. Caution: do not select any other packages. Some dependent packages will be selected automatically upon your two selections: gdal and gdal-python.
- Finish the installation
- You can see OSGeo4W icon ion your desktop. That is a batch file invoking the command line prompt.
- That’s it.
This only works on Windows 32bit machines. For 64bit Windows machines, we need to follow quite different instructions.
GDAL and GDAL2Tiles Setup for 64bit Windows
OSGeo4W cannot be used for 64bit Windows machines. We have to install GDAL and Python manually.
- Install Python from x86-64 Installer at http://www.python.org/getit/.
- Run python.exe. We have to find out the compiler version that built the python. In my case, the Python version is 2.7.3 and it was compiled and built with MSC v.1500.Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)] on win32
- GDAL binary packages for 64bit machines can be found at http://vbkto.dyndns.org/sdk/. Select a corresponding version in the table. In my case, release-1500-x64-gdal-1-9-mapserver-6-0 is the right version in the”MSVC2008 (Win64) -stable” row because the Python was built by 1500.
- Install the GDAL core components. There is no option to choose the destination folder for GDAL core. It will be installed into the “C:\Program Files\GDAL” folder.
- Install the GDAL python bindings.
- After the binding, you may move GDAL folder in C:\Program Files into wherever you want to.
- Add two batch files; gdal.bat and gdal2tiles.bat into GDAL folder. You can find these two bat files below.
@echo off rem --- @echo Setting environment for using the GDAL Utilities. set GDAL_PATH=<full path of your GDAL installation> @echo GDAL path is %GDAL_PATH%. set PATH=%GDAL_PATH%;%PATH% set GDAL_DATA=%GDAL_PATH%\gdal-data set GDAL_DRIVER_PATH=%GDAL_PATH%\gdalplugins set PROJ_LIB=%GDAL_PATH%\projlib rem --- @echo Setting environment for using the Python. set PYTHON_PATH=<full path of your Python installation> @echo Python path is %PYTHON_PATH%. set PATH=%PYTHON_PATH%;%PATH% @echo on @if [%1]== (cmd.exe /k) else (cmd /c "%*")
python %GDAL_PATH%\gdal2tiles.py %*
Now, you are ready to use GDAL2Tiles.
- Just double click gdal.bat.
- Type gdal2tiles with proper options.
You may combine these two into a single command.
- Open a command prompt window.
- Type gdal gdal2tiles with proper options.
Good luck and have fun.