Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

in the python console I can call import gdal, and gdal is recognized as a module; however, most gdal programs, such as gdalinfo and gdalsrsinfo are not recognized. I checked the GDAL source files to see if there was a problem with the PYTHONPATH. They were not in the QGIS application resources, so I moved them manually… this still did not solve the problem.

if i enter gdalsrsinfo /Filepath/File.prj the console returns the error:

Traceback (most recent call last): File "", line 1, in File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 453, in _import mod = _builtin_import(name, globals, locals, fromlist, level) ImportError: No module named gdalsrsinfo

However this is a function that should be included in GDAL by default. Why is it not recognized? I am using the latest version from KyngChaos

Any help appreciated. Thanks!

share|improve this question
5  
Those programs are binaries programs (.exe in windows speak). You need to run them at a proper command line, not in the python console. –  BradHards Feb 4 at 5:59
3  
@BradHards: I feel you should post that as an answer. –  Devdatta Tengshe Feb 4 at 7:28
    
I finally found enough words to make a token answer... –  BradHards Feb 4 at 9:09
add comment

1 Answer 1

GDAL isn't all in python. The core is written in C/C++. You can, of course, use the GDAL/OGR library parts from python

You can also use those library parts using other APIs, including compiled languages such as C or C++. That is what many (although not all) of the command line utilities do. There is a list of command line utilities at http://www.gdal.org/gdal_utilities.html - you can safely assume those that end with .py are python scripts and those that do not end with .py are compiled executables (.exe in windows terms, typically an ELF format program in Linux, or Mach-O on MacOS).

The python utilities are intended to be used from the command line (Terminal.app or similar), just like the executable format utilities. You may be able to make use of them by import in python, or by subprocess but there isn't anything GDAL specific in that invocation.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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