1

I am trying to access ogr2ogr in the command line, and this is the message I receive:

 'ogr2ogr' is not recognized as an internal or external command, operable program or batch file. 

This is current python setup-up. I am using the python version installed with arcgis 10.2 (aka. python 2.7). I have installed and linked Python(x,y) to python itself. I call on arcgis and a variety of python gis function using the Spyder editor, which comes with the Python(x,y) editor.

I installed a compiled gdal package from:

http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy

Now I am able to call the gdal function inside of Spyder, but I am unable to call ogr2ogr from the command line. I did not create a environmental variable for windows yet. My primary issue is that I dont know how create a enviornmental variable for gdal that allows me to call ogr2ogr in the command line, given that I am using the compiled gdal package.

Does anyone know what to do?

Here is the location of the ogr2ogr on my installation:

C:\Python27\Lib\site-packages\osgeo\ogr2ogr.exe

  • you could try using the full path in your command line as a workaround. – radouxju Apr 10 '14 at 20:38
3

You need to have admin privileges on the box.

For Windows 7:

  1. Click on the start menu.
  2. Right click on "Computer"
  3. Click "Properties"
  4. Click "Advanced system settings on the left menu bar
  5. You may have to type in a password here.
  6. The second box is titled "system variables" on of them is "PATH"
  7. Select path, click edit.
  8. Go to the end of the PATH variable and add the string (the semicolon isrequired)

    ;C:\Python27\Lib\site-packages\osgeo\
    
  9. Ok/Save your way back out and close the window.

  10. The windows command line loads the system path at start up, so you'll need to reopen any open terminal to access the change.
  • I will try your solution in a couple of minutes. Already thanks for the proposed solution! – user1738753 Apr 10 '14 at 20:42
  • if you don't have admin privilege you can open a command prompt ad type "set path=%path%;c:\python27\lib\site-packages\osgeo" or similar depending on your path to ogr2ogr executable. This setting is valid for the duration of this particular command window, will not affect any other command windows or programs and is gone when the command window is closed. This wont help with spider but if you need to call ogr2ogr from the command line it works. – Michael Stimson Apr 13 '14 at 5:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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