3

I have QGIS installed, therefore it installed the OSGeo4W with all functionalities and that works great.

I added all the environment variables as proposed in this post: Is there a way to use gdal functions from OSGeo4W out of their shell?

But what I'm looking for is to actually be able to use my normal Python shell outside OSGeo4W and :

import ogr

This is since I'm using Apache Spark to make some analysis I don't want to have two different Python environments.

2
  • what is your 'normal' python shell? pure python? some other distribution? installed by arcgis? - 32 vs 64 bit? - these could make a difference as to if ogr can be imported into the default python shell. Jul 17, 2016 at 15:01
  • Pure python (downloaded at python.org), 64 bits. @fluidmotion. I do not use ArcGIS only QGIS.
    – gracegimon
    Jul 18, 2016 at 12:05

1 Answer 1

1

If you are looking for pure python with gdal on your cmd you need to do follow steps:

Step 1: Install pure python from python.org

Feel free to download the latest 2.7x version of python (rather than the 3.x python version). Install python with the default options and directories.

Step 2: Next Install the GDAL Binaries

Head over to Tamas Szekeres’ Windows binaries and download the appropriate GDAL Binary.

Install gdal core and next install gdal bindings for your version python.

Step 3: Adding Path Variables:

  1. Right click on “Computer” on the desktop and go to “Properties”

  2. Click on Advanced System Properties

  3. Select Environment Variables.

  4. Under the System variables pane, find the ‘Path’ variable, then click on Edit.

  5. Go to the end of the box and copy and paste the following: ;C:\Program Files (x86)\GDAL Note: For 64-bit GDAL installations you would simply remove the (x86) after Program Files.

  6. In the same System variables pane, click on “New” and then add the following in the dialogue box:

    Variable name: GDAL_DATA

    Variable value: C:\Program Files (x86)\GDAL\gdal-data

  7. Click “OK”

  8. Add one more new variable by clicking “New…”

  9. Add the following in the dialogue box:

    Variable name: GDAL_DRIVER_PATH

    Variable value: C:\Program Files (x86)\GDAL\gdalplugins

For testing GDAL install open command line and type: gdalinfo --version

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.