| 
  • This workspace has been inactive for over 11 months, and is scheduled to be reclaimed. Make an edit or click here to mark it as active.
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Work with all your cloud files (Drive, Dropbox, and Slack and Gmail attachments) and documents (Google Docs, Sheets, and Notion) in one place. Try Dokkio (from the makers of PBworks) for free. Now available on the web, Mac, Windows, and as a Chrome extension!

View
 

Using GDAL with Python

This version was saved 10 years, 12 months ago View current version     Page history
Saved by J A Glennon
on December 9, 2010 at 12:31:25 pm
 

Installation Instructions for Windows

Python, GDAL, and Python/GDAL bindings

23 October 2009 -- written and tested by A. Glennon; Python conflict note from K. Grossner
(((A few update notes, 9December 2010: Since Python and GDAL versions continue to update, often you will not be able to use the absolute latest versions to bind Python and GDAL; you'll need to find the most-recent combination that works. For those without much Python/GDAL experience, an easy solution is to install FWTools instead; FWTools is a free and open source tool set that includes compatible versions of Python, GDAL, and the appropriate bindings.)))
 
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.
 
NOTE: There will be a problem if you have ArcGIS installed on your computer. Python is by default part of the ArcGIS installation. The environment variable, PYTHONPATH is set to the ArcGIS/bin subfolder on your computer, where a copy of python.exe resides. Using GDAL requires that PYTHONPATH be set to the location of your new Python installation after Step 1. Environment variables are set and edited as discussed in Step 3 below. There appears to be no adverse effect for ArcGIS use upon making this change. That is, ArcGIS will use the version found on PYTHONPATH, wherever that is.
 
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.