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.

2
  • The script makes no sense. You can print the values of data, sizeY and sizeX. It will see why. Commented Apr 13, 2016 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. Commented Apr 14, 2016 at 16:42

1 Answer 1

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"
PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
answered Apr 18, 2016 at 22:30

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.