0

i'm using OSGeo4W64 (gdal 2.0.2-8) with Python 2.7.5 on Windows 8.1 64bit. Editor is PyCharm 2016.1.2.

I want to save an image with gdal, but i always get an error when the python script is complete. The following example causes the error:

from osgeo import gdal
import numpy as np

path = 'D:\\test.tiff'
data = np.array([[1]])   
sizeY = int(data.shape[0])
sizeX = int(data.shape[1])
bandCount = 1
driver = gdal.GetDriverByName("GTiff")

dataSet = driver.Create(path, sizeX, sizeY, bandCount, gdal.GDT_Byte)
band = dataSet.GetRasterBand(1)
band.WriteArray(data)  # causes error, if commented out, everything is fine

band = None
dataSet = None

print "the appcrash will come next"

I'm dereferencing the vars and it should be fine, but i'm getting "python.exe has stopped working".

The console shows:

the appcrash will come next

Process finished with exit code -1073741819 (0xC0000005)

When i run the code in QGIS (2.14.1) and i close QGIS, a similar error occurrs and a dump file was created.

Process Name:   qgis-bin.exe : C:\OSGeo4W64\bin\qgis-bin.exe
Process Architecture:   x64
Exception Code: 0xC0000005
Exception Information:  The thread tried to read from or write to a virtual 
address for which it does not have the appropriate access.

My GDAL-Enviroment-Vars are:

GDAL_DRIVER_PATH=C:\OSGEO4~1\bin\gdalplugins
GDAL_DATA=C:\OSGEO4~1\share\gdal

I have no idea why this error happens (maybe something with the dereferencing). The error might be similar to here.

  • The script makes no sense. You can print the values of data, sizeY and sizeX. It will see why. – xunilk Apr 13 '16 at 16:04
  • It's just a test setup, which creates a pixel with the value of 1. Data can be any grayscale image data. – douni Apr 14 '16 at 16:42
1

I had such problems with not only python gdal binds but with standard gdal apps: gdalwarp, gdal_translate and so on.. So the problem was solved after full reinstall of all gdal and python reminds in system with refreshing path and gdalpath enviroment vars. The fastest way:

  1. Install Anaconda https://www.continuum.io/downloads,
  2. Install GDAL core from gisinternal http://www.gisinternals.com/release.php with refreshing env vars
  3. From Anaconda direcory execute "conda install gdal"

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.