| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

Using GDAL with Python

This version was saved 14 years, 5 months ago View current version     Page history
Saved by J A Glennon
on October 23, 2009 at 7:32:39 pm
 

Installation Instructions for Windows

Python, GDAL, and Python/GDAL bindings

23 October 2009 -- written and test by A. Glennon
 
Note: This sometimes can get quirky if you have ArcGIS installed. ESRI's installation often alters that global Python paths. You might search online for: upgrading arcgis python.
 
1. Go to http://www.python.org/download/ and install Python 2.6. Python 2.6.x Windows Installer is probably the best one to use. Download, double click the package, and follow the onscreen installation instructions.
 
2. Get GDAL. For Windows, a good place to get it is: http://download.osgeo.org/gdal/win32/1.6/ It'll have a name like: gdalwin32exe160.zip. With that file, when you unzip it, it should be a folder called gdal32-1.6 (or similar) with two folders in it: bin and data. Place the gdal32-1.6 whereever you prefer, but note where it is. You'll need the path name later. I'll place mine at: c:\gdal32-1.6
 
3. You now need to modify your Windows system path and an environment variable. Here's what you do: a) In Windows, find "My Computer", right click your mouse to reveal a context menu, and select "Properties". This will yield a System Properties window. Select the "Advanced" tab, and click the button "Environment Variables". This opens an Environment Variables window. In the user variables area, click on "New" button. This opens a dialog box. Fill in the boxes with the following information:
 
Name: GDAL_DATA
Path: C:\gdalwin32-1.6\data
 
Click OK. Next, in the System Variables section, scroll down until the variable "Path" is highlighted. Click the "Edit" button; it will open a dialog box called Edit System Variable. Leave the variable name "Path" unchanged. The Variable value area is a small box usually overflowing with variables. Make sure not to delete any of those variable names. If you accidentally do, click cancel. Otherwise, after all the existing variables in the small dialog area, add a semicolon, then the path to your gdal bin folder(something like this: ;C:\gdalwin32-1.6\bin). Click the OK button, and it will close that Edit System Variable window. Click the OK button at the bottom of the Environment Variables dialog window. Click the OK button at the bottom of the System Properties' Advanced tab. An additional note or two: You may want to log out and then back in to Windows so it will refresh the variables you just set. Also, if you open a Command Prompt in Windows, and type: ogr2ogr, you should receive usage notes on the function. If it's not working, you will get an error message that ogr2ogr cannot be found.
 
4. Now, you'll need the bindings to make GDAL and Python work together. Head over to http://pypi.python.org/pypi/GDAL/,look near the bottom of that website, and grab the MS Windows installer for Python 2.6. It will be called something like: GDAL-1.6.1.win32-py2.6.exe. Download, double click on the package, and follow the onscreen installation instructions. 5. you can test to see if it worked by going into a Python shell and typing: from osgeo import ogr. If it doesn't work, you might try restarting your computer.

Comments (0)

You don't have permission to comment on this page.