2

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

3
  • 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
    Commented Feb 4, 2014 at 5:59
  • 3
    @BradHards: I feel you should post that as an answer. Commented Feb 4, 2014 at 7:28
  • I finally found enough words to make a token answer...
    – BradHards
    Commented Feb 4, 2014 at 9:09

1 Answer 1

7

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.

Your Answer

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

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