Install GDAL on Windows
Later posts on this blog will assume a working install of GDAL/OGR, so it’s prudent that I first demonstrate how to get a fresh cut of GDAL/OGR up-and-running on a Windows system.
Windows users have a few options for installing GDAL (see this question at gis.stackexchange,which will point you to Christoph Gohlke’s binaries –scroll down to GDAL, and the OSGeo4W Installer, among other approaches). However, I’ll guide you through what works for me, which can be summarized as follows:
1) Install Python
2) Install the GDAL binaries published by Tamas Szekeres
3) Append your environment Path variable
4) Add the GDAL_DATA environment variable
5) Finally, perform a quick test to make sure everything worked.
First, Install Python
(For reference purposes, I used version 2.7 for Win32):
· Start at the Python homepage
· At left, find “Quick Links (2.7.2)” and select “Windows Installer”
· Complete the download and start the installation
· Accept the default options suggested by the installer
Once Python is installed, launch IDLE (the built-in Python IDE) to get specific details about your Python installation:
Follow Windows (Start)→Programs→Python 2.7→IDLE (Python GUI)
This figure emphasizes where to look:
In this case, I’m noting the following values:
· “MSC v.1500”
· “on win32”
Your values may be different than mine. For instance, you may have v.1400? Or maybe you installed 64-bit Python on a 64-bit system? Whatever you did, you’ll need to be consistent from here on out. Since these values will be important in the next step, you may want to keep the IDLE window open for a few minutes.
Next Install the GDAL Binaries
From the GDAL homepage, you’d navigate to Downloads→Windows, and open Tamas Szekeres’ Windows binaries. When Tamas’ page loads, you’ll need to identify the proper download package for your version of Python, system bit-depth, and VC dependencies.
Note: VC2005, VC2008, VC2010 refer to various dependencies upon C++ redistributable libraries. To get your very own, just Google “c++ redistributable” and pick up the most current release. Alternatively, if you want to play it uber-safe, download and install Visual C++ Express 2010, and it will automagically qualify you for MSVC2010 builds (which equates to the compiler used to build GDAL).
At Tamas’ site, do the following:
· Scroll down to “GDAL and MapServer latest release versions”
· Find a release corresponding to both your installed C++ redistributable library AND your Python install. For instance, I used “release-1500-gdal-1-8-0-mapserver-6-0-0”, which corresponds to MSVC2008 (Win32) in the left column (note the figure).
Selecting a release will take you to a new screen promoting a handful
of EXE and MSI files—to use ogr2ogr, you’ll need two of these.
· Download and install gdal-18-xxxx-core.msi (where xxxx is 1310, 1400,
1500, or 1600, which matches your Python setup). I recommend keeping the defaults while installing.
· Next download and install the GDAL binaries for your version of Python (i.e. 2.6, 2.7, 3.1). Your choice should match the bit-depth and version of Python you installed in the first place. In keeping with my running example, I used GDAL-1.8.0.win32-py2.7.msi. Once again, run the installer and accept the defaults.
Note: The GDAL installer should detect the Python instance installed in the previous section (see Figure 1-9). If not, first review the steps in the previous section to see if you omitted something (this may indicate the GDAL binaries do not match your installation of Python), otherwise select “Python from another location” and proceed cautiously.
Set the Environment Variables
We’re nearly finished installing GDAL. In this section, we’ll configure the Windows environment variables (Path and GDAL_DATA) so the GDAL/OGR utilities will be easily asccessible from the command line.
Append the Path Variable
First, append the GDAL installation directory onto the existing Path variable. Do the following to edit the Path variable:
· Open the Control Panel (Start→Control Panel), open System and select “Advanced System Settings”.
Note: Alternatively, you can open the Windows (Start) menu, right-click “Computer”, select Properties, then select “Advanced System Settings”, which I find easier.
· Select “Environment Variables” (near the bottom).
· Find “Path” among the list options and select it.
· With “Path” selected, click the “Edit” button.
· When the Edit System Variable dialog appears, scroll to the end of the series, add a semi-colon (;) to separate the prior path from the new one you’re about to enter, then add your GDAL installation path. I added exactly this: ;C:\Program Files (x86)\GDAL
· Keep the Environment Variables dialog open for the next task.
Warning: Be sure to confirm your GDAL installation directory. I installed GDAL on Windows XP, but if you run a newer version of Windows, your installation path may be different from mine.
Add the GDAL_DATA Variable
Next we’ll add a new System Variable, GDAL_DATA, which helps the various GDAL utilities find the gdal-data folder. Without access to the files in the gdal-data folder, GDAL may have trouble recognizing some projections and coordinate systems, among other things.
In Windows, create the GDAL_DATA variable as follows:
· In the Environment Variables dialog, click “New” (near the bottom).
· In the New Variable dialog, enter GDAL_DATA for the name value.
· For value, enter the path to your gdal-data folder; it should be one level below your GDAL directory, which you can confirm by scouting the GDAL folder. I used: C:\Program Files (x86)\GDAL\gdal-data
Once again, confirm the gdal-data directory makes sense relative to your GDAL installation folder.
· At this point, commit your changes by selecting “OK” on each dialog.
[Update 1 Oct, 2013]
Add the GDAL_DRIVER_PATH Variable
In the same way you added the GDAL_DATA variable, add a GDAL_DRIVER_PATH variable. This variable is necessary for the Python environment to locate various GDAL driver plugins. Like the gdal-data directory, the gdalplugins directory should be one level below your GDAL installation. Of course, confirm the path on your system. (I’m on Win 7 at this point–note this is inconsistent with the screenshot, above).
On my system, the gdalplugins directory is: C:\Program Files (x86)\GDAL\gdalplugins
For those who already have GDAL installed along with the Python bindings–If you’re trying to write custom scripts and you’re getting errors like ERROR 4: ..does not exist ..is not recognized as a supported dataset name, you may simply need to add this additional environment variable. This is especially true if you followed my tutorial for setting up GDAL on your system in the first place! In case of the latter, my apologies.
Confirming a Successful GDAL Installation
To confirm the availability of ogr2ogr, just open a new command terminal and attempt to call ogr2ogr. If your installation is successful, ogr2ogr will start running, fail to find any valid runtime arguments, and close, leaving some helpful usage hints in its wake.
To test ogr2ogr in a Windows Command Prompt, do the following:
· Open the Windows (Start) menu, and at the bottom (“Search programs and files”), type cmd and hit Enter; this will open the Command Prompt.
· With the terminal open, type ogr2ogr and hit Enter (see the image).
Because we added the GDAL installation directory to the Path variable, Windows will attempt to find a valid ogr2ogr executable in the GDAL folder. If all goes well your command prompt should resemble the following figure (the ogr2ogr command is highlighted).
————————
[Update 27 Jan, 2014]
Change in testing/confirming a successful install
My initial recommendation to just type “ogr2ogr”, which resulted in an error (which I warned you’d get), was confusing for several people. In hindsight, I agree it was a poor choice on my part. So I like this better:
At the command prompt, type this:
gdalinfo --version
And the OGR module should respond with something like this:
C:\Users\elrobis>gdalinfo --version GDAL 1.9.2, released 2012/10/08
Assuming you get a version number and a release date, and not an error, you should have a clean install of GDAL/OGR to work with. Be warned, though, getting the version output doesn’t confirm that your environment is setup properly, if that stuff isn’t right, you’ll likely get errors when you actually apply GDAL or OGR to some task.
————————
And voila! Assuming you see the Usage/Help output, you should be good to go with a fresh GDAL/OGR installation.
Cheers, Elijah
[Edit 06.22.2012]
If you plan to create your own Python utility scripts with the OGR Python bindings, I further recommend the following Python libraries:
shapely, numpy, Python Image Library (pil), PostgreSQL Adapter (psycopg), MySQL Adaptor (mysql-python), Python Shapefile Library (pyshp), Dbase/Xbase Adaptor Library (pydbf), matplotlib
Thank you very much Elrobis. The instructions were straightforward and very helpful. I have been trying to install GDAL on my computer a while ago in vain. With your instructions, I definitely installed it.
Thank you once again
Alassane
Alassane
22 Jun 12 at 1:37 am edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
That’s great, Alassane, thanks for the feedback. I’m glad the post benefitted you. Cheers! elrobis
elrobis
22 Jun 12 at 9:58 am edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
Wonderful! you made it so simple.
Farhat Abbas
15 Aug 12 at 3:51 am edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
Thanks Elrobis, for the straightforward instructions. They were very helpful to me.
LSerra
16 Nov 12 at 5:11 pm edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
Libraries cannot be loaded in my computer.
I set the path from PostgreSQL:
C:\Program Files\PostgreSQL\9.1\gdal-data
and variable name to
GDAL_DATA,
but no libraries got loaded.
Please help me out.
Thank you.
SriRamaChandra
17 Dec 12 at 4:18 am edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
Thanks for the guide.Do you know how to add HDF4 support to this? This doesnt recognize the EOS HDF 4 files.
Singh
10 Jan 13 at 11:13 am edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
Thank you so much. One of the best tutorials I have read in a while!
asdf
5 Mar 13 at 1:50 pm edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
[…] am trying to install GDAL for Python 2.7. I have followed the instruction in the http://cartometric.com/blog/2011/10/17/install-gdal-on-windows/ link and went through step by step. I set in environment variables as recommended. When I want to […]
error on installing GDAL for Python 2.7 | BlogoSfera
27 May 13 at 12:02 pm edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
Thank you very much. Lots of information over here http://gis.stackexchange.com/questions/2276/how-to-install-gdal-with-python-on-windows
But this was the simplest for what I wanted to do
Luke
3 Jun 13 at 12:38 am edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
thanks a lot! it was just worked like a charm !
geoendemics
8 Oct 13 at 7:57 am edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
At the very end, after typing ogr2ogr on the CMD screen, there was a “FAILURE: no target datasource provided”.
–
What did i do wrong? I’ve followed all the steps.
Felipe
24 Oct 13 at 10:02 pm edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
@Filipe, see my replies to hubert and Alex. My post notes that the simple “ogr2ogr” instruction, which doesn’t include any usage parameters, will result in a failure. But obviously this was a poor choice on my part. I’ll change the post to recommend having ogr2ogr output its version or something. I wish I’d thought of that initially. Sorry to recommend such a confusion manner of confirming everything was installed properly.
elrobis
27 Jan 14 at 9:06 am edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
Hi
I’m also getting the message:
“FAILURE: no target datasource provided”
Does this mean that I have been unsuccesfull in the installation of gdal?
Alex
6 Nov 13 at 9:06 am edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
@Alex, please note my reply to hubert. You (probably) have GDAL installed correctly–it’s just not finding valid instructions and therefore throwing the error. Since folks don’t seem to gather that, I’ll change the post to recommend something less scary to confirm the install.
elrobis
27 Jan 14 at 9:03 am edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
[…] http://cartometric.com/blog/2011/10/17/install-gdal-on-windows/ […]
Visualización 3D con Python (gdal, numpy y matplotlib) en Windows | El Blog de José Guerrero
20 Nov 13 at 5:16 am edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
Hey,
I have the same problem:
“FAILURE: no target datasource provided”
What went wrong?
hubert
10 Dec 13 at 3:33 pm edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
@hubert, it seems to me it worked. I’ll restate a remark in my original post. Please note the bit about it failing.. “If your installation is successful, ogr2ogr will start running, fail to find any valid runtime arguments, and close, leaving some helpful usage hints.” This post was just intended to assist with the installation of GDAL, not instruct on its usage. So based on the info you provided, I think you have it installed, now you just need to use it for something.
elrobis
27 Jan 14 at 8:59 am edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
Has worked for me! Thank you very much.
Edson
4 Feb 14 at 5:39 am edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
Thank you so much.
You made this tutorial so simple.
Marco Abbuonandi
8 Feb 14 at 4:39 am edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
This was invaluable. Thank you.
Kasparas
11 Feb 14 at 9:38 am edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
Thank you very much, I’d never have been able to find this out by myself. One thing that confused me is that the core installer file is missing from the latest win32 1500 release (release-1500-gdal-1-10-1-mapserver-6-4-1), so I had to get an older release. Obviously, that’s not your fault though.
Roger
13 Feb 14 at 8:28 am edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
Hi there,
These are really useful instructions I have followed them however I am having trouble getting python to see the osgeo modules. Are you able to provide some instructions how to test python to make sure it is correctly configured? I ahve installed Python with ArcGIS and have a 32bit and 64bit installation on a 64bit machine.
Regards,
Marc
Marc
26 Feb 14 at 6:24 pm edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
Hi Marc. The instructions in this post assume a vanilla Python installation (that is, beginning with a basic Python installer, which goes into a default directory). But you *should* be able to adapt these instructions to a different variety of Python installation. Because it’s possible to have multiple instances of Python installed on your system, you just need to make sure that all the components are getting wired to the right one. For example–when you install the GDAL binaries (see the 3rd screen grab in the blog), you can select “Python from another location”. I’ve never followed that route before, so I’m not sure what options it will give you, but you’d want to make sure and select the ArcGIS Python instance. I suspect the PATH, GDAL_DATA, and GDAL_DRIVER_PATH would not be different from the advice I provided in the post. You might also want to review the notes in this post, which discusses entanglement of the vanilla Python instance and the ArcGIS Python instance, and shows how I was able to install a Python library targeting a specific instance of Python. This might be important if, for instance, the “Python from another location” doesn’t automatically suggest the ArcGIS alternate instance. Please realize that I’m mostly guessing here, but it is a relatively educated guess.
There is one warning I want to throw out there. Ultimately you’re desiring to “mutate” the Python instance running in support of ArcGIS. Fundamentally, I think it should be fine okay. However, there is a possibility of compromising the ArcGIS Python instance by introducing alternate influences. And I can promise you it’ll be much easier to destroy it than it will be to fix it after the fact! Having said that, however, I can certainly appreciate the interest in having ArcPy and all your other modules running out of a preferred Python instance—it just makes me wonder, if the ArcGIS Python instance is not sensitive, why would they give it its own installation directory and not expose it to the registry so that other Python modules would detect its presence? Know what I mean? ..like, almost as if they wanted to disguise it from 3rd party modules. If that’s the idea, it’s almost got to be for the purpose of keeping it clean and uncompromised by 3rd party stuff.
Hopefully something in that rambling is helpful to you!
Best, Elijah
elrobis
27 Feb 14 at 4:25 pm edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
Great tutorial. Wouldn’t have been able to figure this out without it. Thanks much.
bhickson
20 May 14 at 3:31 pm edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
This link was helpful and i have installed it correctly.
Srinivasan
30 Jun 14 at 9:25 am edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
Thank a lot !, I used this for install gdal with python and used for my tesis. Maybe you want to add this to your tutorial:
Testing/confirming a successful install working with Python
At the command prompt, type this:
python
And Python should respond with something like this:
Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)] on win
32
Type “help”, “copyright”, “credits” or “license” for more information.
>>>
In the promt (>>>) write: from osgeo import gdal
If you dont get any error mesagge (just the promt again: >>>) then GDAL can be used in Python
Cheers
Yanina
Yanina
15 Jul 14 at 6:56 am edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
Awesome work. Thank you so much!
Darrick Roberts
16 Jul 14 at 5:59 pm edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
Got this running smooth as butter. Great work. Thanks!
Phyn
17 Jul 14 at 12:39 pm edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
I have just spent a few days and many hours trying to install gdal on a Windows 7 computer that runs ArcGIS 10.0 and therefore Python 2.6 or 2.6.5. Your page got me the closest to a solution – thanks! The final thing I had to figure out is that the most recent gdal packages for my MSC/bit/etc. don’t include an installer for Python 2.6. To find that I had to go a bit back in time on the page with all the installers to here: http://gisinternals.com/sdk/PackageList.aspx?file=release-1500-gdal-1-10-1-mapserver-6-4-0.zip
And I finally have gdal working on the computer! So relieved. I hope this comment helps someone else in my position.
Maritza
25 Aug 14 at 6:43 pm edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
Thank you!!!
Alan Stanton
28 Aug 14 at 6:34 pm edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
Thanks. It was very helpful for me.
KD Nam
31 Aug 14 at 7:56 am edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
Hi,
It took me 2 days to find a right website on how to use GDAL in simple terms. Even the GDAL.org doesnot provide the above steps. Thanks for the post. This helped me.
Programmer
24 Oct 14 at 10:25 am edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
HI,
thanks for the post.
My problem is that the installation works, but I am unable to import modules in python. Any clue?
Thanks,
Daniel.
Daniel
5 Nov 14 at 10:12 am edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
[…] controlling gdal2tiles.py by a management line. we followed instructions on installing gdal from http://cartometric.com/blog/2011/10/17/install-gdal-on-windows/ we afterwards accurate by management prompt that gdal was hallowed by typing in gdalinfo […]
gdal2tiles.py no input file specified, wrong formatting? | Alvina
15 Dec 14 at 8:26 pm edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
Hello,
Thank you for the post. The installation works 🙂
Aswin
2 Jan 15 at 12:08 am edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
Highly useful…..
Drisya
8 Feb 15 at 11:52 pm edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
Thank you, Great article. Even though I had done this in the past with other versions of python, on another computer, I was having trouble today until I found your article.
RDell
9 Feb 15 at 1:10 pm edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
although the installation works well, when importing the gdal in python window generates” no module named gdal” can anyone suggests?
Drisya
9 Feb 15 at 11:49 pm edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
[…] http://cartometric.com/blog/2011/10/17/install-gdal-on-windows/ […]
How to retrieve PROJECTION value for a map? | DL-UAT
15 Feb 15 at 12:00 am edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
I’m experiencing similar issues as Drisya. I’ve reloaded python with the current edition, 2.7.9 with 32-bit, running windows 7 with 64-bit compatibility. The step-by-step instructions were pretty straightforward. I have versions of the C++ compiler for both 32-bit and 64-bit and I’m wondering if this is possibly causing errors. Also, all of my downloads go to the C:\Program Files (x86)\GDAL folder as specified. I’m working with the latest version of GDAL as listed, 1.11.1 and have a similar build with the 1500 version.
Mortsde
5 Mar 15 at 8:37 pm edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
[…] PostgreSQL or MySQL. The best tool for this, of course, is the ogr2ogr command line utility in the GDAL/OGR suite. It’s the best for many reasons. But in this context, it’s the best because everything […]
Q: What’s The best way to convert CDs to MP3s in Windows? A: VLC and the Command Line. Here I’ll show ya.. at Cartometric Blog
7 Mar 15 at 5:37 pm edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
works for me … thanks
costea
18 Mar 15 at 1:04 am edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
[…] run the procedure outlined in http://cartometric.com/blog/2011/10/17/install-gdal-on-windows/ […]
gdal ImportError in python on Windows | DL-UAT
19 Apr 15 at 9:07 pm edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
Thank you very much! Been trying to install gdal/ogr for days (haha), but now it works perfectly thanks to your explanation!
ida
23 Jul 15 at 2:57 am edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
Elijah, you rock!
Thanks oh so much for such clear and concise tutorial! I would have never otherwise have figured this installation out by myself!
Cheers,
R.
RJP
10 Sep 15 at 9:40 am edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
[…] makes a good point. Also, that I know of, there are at least three (maybe more?) environment variables that need attention: PATH (;C:Program […]
Python:Unable to install Python and GDAL (DLL load failed) – IT Sprite
29 Sep 15 at 9:37 pm edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
[…] La forma que me funcionó mejor de todas es la que explican en este post: Cartometric.com – Install gdal on Windows […]
Transformar ficheros osm de OpenStreetMap a Shapefile usando ogr2ogr de GDAL | másquesig
4 Nov 15 at 3:35 pm edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
very pleased to see this step by step instructions to install GDAL on windows OS. I have successfully installed it. Actually i was installing pyModis python package GDAL was the prime requirements to install it before. Now when i type the command in WindowsPowerShell:
C:\>python
>>import pymodis
I see the following message
ERROR 1: Can’t load requested DLL: C:\Program Files (x86)\GDAL\gdalplugins\gdal_GMT.dll
127: The specified procedure could not be found.
ERROR 1: Can’t load requested DLL: C:\Program Files (x86)\GDAL\gdalplugins\gdal_GMT.dll
127: The specified procedure could not be found.
ERROR 1: Can’t load requested DLL: C:\Program Files (x86)\GDAL\gdalplugins\gdal_netCDF.dll
127: The specified procedure could not be found.
ERROR 1: Can’t load requested DLL: C:\Program Files (x86)\GDAL\gdalplugins\gdal_netCDF.dll
127: The specified procedure could not be found.
Traceback (most recent call last):
File “”, line 1, in
File “build\bdist.win32\egg\pymodis\__init__.py”, line 5, in
# package placeholder
File “build\bdist.win32\egg\pymodis\qualitymodis.py”, line 36, in
File “C:\Python2.7\lib\site-packages\osgeo\gdal_array.py”, line 137, in
gdal.AllRegister()
RuntimeError: Can’t load requested DLL: C:\Program Files (x86)\GDAL\gdalplugins\gdal_netCDF.dll
127: The specified procedure could not be found.
Would you please guide me accordingly where i am getting wrong
Waseem
17 Nov 15 at 11:26 am edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
Used these packages on 64 bit system:
– python-3.3.5.amd64
– gdal-111-1800-x64-core
– GDAL-1.11.3.win-amd64-py3.3
Works like a charm.
Parthesh
11 Dec 15 at 4:13 am edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
Extra step needed. Set PROJ_LIB system variable to “C:\Program Files (x86)\GDAL\projlib”, otherwise CS2CS command won’t convert between NAD27 and NAD83 correctly.
Michael Newman
18 Feb 17 at 7:17 am edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
If you’ve installed on Windows using the OSGeo4W64 network installer with default settings then the GDAL_DATA path will need to be C:\OSGeo4W64\share\gdal and the folder to add to your path should be C:\OSGeo4W64\bin
Ken Goulding
15 Jun 17 at 8:48 am edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
[…] little installer called OSGEO4W which can be used to install GDAL and other important utilities. Here is an amazing tutorial to install GDAL with Python binding in […]
Making use of GDAL, RSGISLib and OTB with Python – ClubGIS
10 Jul 17 at 5:09 am edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
I followed the instructions here to install GDAL to use with Python 2.7 (32-bit) and ArcGIS. Everything seemed to work all the way through to the successful testing of ogr2ogr. However, how do I import gdal into my Python programs? The “from osgeo import gdal” response says the specific module cannot be found. Should I be importing from somewhere other than osgeo? — Thanks.
Alisa
2 Jun 20 at 3:46 pm edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
Hi Alisa. Given your error, it sounds like the version of Python you’re using can’t see the GDAL bindings. Of note: ArcGIS installs its own version of Python. Are you trying to call GDAL from the ArcGIS Python environment? If so, you’ll have to tweak the installation instructions accordingly.
If you have multiple versions of python installed, your computer will associate one of them as, simply, “Python” in the command line. Your command line might also respond to “Python27” or “Python3”. Alternate Python installation can be referenced by using a fully-qualified path. The ArcGIS Python will (probably?) live somewhere behind the ArcGIS installation directory, like C:/Programs/ArcGIS/more/stuff/python27, whereas a stand-alone Python installation will live closer to the drive root, like C:/Programs/Python27.
Another thing to be mindful of, it’s 100% possible to have Python26, Python27, Python3 ..even a second Python27 installed to a non-default directory (like ArcGIS’s) all on the same system, concurrently. However, only *one* of those instances will respond as “python” when called from the command line. If you check your PATH variable, your system should call the first instance of a Python interpreter it encounters as it parses the different PATH values available to it. So if your path has C:/Programs/Adobe;C:/Programs/Python26;C:/Programs/Sierra;C:/Programs/Python27.. When you type “python” on the command line, it’ll default to using your Python26 instance, or some other Python which may not be the version you accommodated with GDAL bindings.
So, assuming you didn’t have any issues with my instructions, my first bet is you’ve unwittingly got multiple versions of Python, and the GDAL stuff will work (i.e. “from osgeo import gdal”) if you can figure out which version of Python it was installed against. My second bet would be that you’ve got a mismatch between the version of Python/C++ redistributable libs you actually have, and the version you downloaded from Tamas’ website. That stuff can be kind of confusing, and admittedly I’m still not sure I explained it all correctly.
elrobis
2 Jun 20 at 4:27 pm edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
One more thought …. what happens if you just type “import ogr” as opposed to “from osgeo..” ?
elrobis
2 Jun 20 at 5:00 pm edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
elrobis — I really appreciate your detailed response. So, yes, it turns out that I did have GDAL living in a parallel universe to Python and ArcGIS and they could not see each other. In addition, I have two separate installations of ArcGIS, so I needed to make sure to point to the one under which Python lives. I uninstalled GDAL and ran through all the steps in your directions again, paying close attention that pathways and environment variables all agreed. I now can successfully implement a gdal command in the Python shell. Yay! Many thanks!
Alisa
3 Jun 20 at 1:11 pm edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
Hey that’s great! Glad I was able to help. And congratulations on the successful custom install!
elrobis
3 Jun 20 at 2:56 pm edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>