0

I used the instructions at https://pythongisandstuff.wordpress.com/2011/07/07/installing-gdal-and-ogr-for-python-on-windows/

I downloaded the following files:

  • GDAL-1.11.1.win-amd64-py2.7.msi
  • gdal-111-1800-x64-core.msi

Then I followed the above instructions. When I type

from osgeo import gdal

at the Python IDLE command line, everything appears to be OK. Then I type in

ds = gdal.Open( 'C:/testfile.DT1')

and again, it appears to be OK. However, when I type in

gt = ds.GetGeoTransform()

I get the following error message:

Traceback (most recent call last):
 File "<pyshell#3>", line 1, in <module>
 gt = ds.GetGeoTransform()
AttributeError: 'NoneType' object has no attribute 'GetGeoTransform'

I have checked the DTED file and there is nothing wrong with it. I also tried the above with a tif and got the same result. I can get the GDAL executables to run, but not the GDAL Python scripts. Is there something that I should check regarding my install of GDAL?

Chris W
15.8k2 gold badges30 silver badges47 bronze badges
asked Jul 17, 2015 at 18:52
2
  • 8
    If gdal can't open your file for some reason it just returns None instead of raising an exception. To see the error, call gdal.UseExceptions() before attempting to open the file Commented Jul 17, 2015 at 23:08
  • 4
    the gdal.Open method returns None if no dataset is found, for some reason the dataset is invalid or GDAL can't open it. Try GDALinfo on the dataset to see if it's valid or incomplete/corrupt. As @Luke said, set the UseExceptions to find out what the error is. Is your python 64 bit as well? You can't mix 64/32 bit. Do you have more than one python install? Is your GDAL environment set up properly? (trac.osgeo.org/gdal/wiki/ConfigOptions) is DTED a core driver or do you need to get that separately? Commented Jul 18, 2015 at 0:12

1 Answer 1

-1

Maybe try to open like this:

from osgeo import gdal
driver = gdal.GetDriverByName( ’DTED’)
driver.Register()
file = gdal.Open( ’path/to/file’)

You may have to register your driver, in this case DTED.

Michael Stimson
25.7k2 gold badges36 silver badges75 bronze badges
answered Jul 17, 2015 at 19:00
3
  • Thanks for this answer. However, I got the same resulting error. Commented Jul 17, 2015 at 19:33
  • So maybe your path to file is wrong. Try: C:\\testfile.dt1. A backslash instead of a slash. Commented Jul 17, 2015 at 19:37
  • 4
    All drivers in the library are registered with from osgeo import gdal No need to register anything, unless you've deregistered. Commented Jul 17, 2015 at 21:32

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.