python crashes with returned gdal band object from a function

المشرف العام

Administrator
طاقم الإدارة
I wrote these two functions in a module when I want to read the band in NetCDF or HDF files and return the band outside the function. Each HDF and NetCDF has many subdatasets. Each subdataset in a NetCDF file has 365 bands while HDF subdataset has only one band. When I run readFile1, there is no problem. However, when I run readFile2 and return the band, I type out.GetNoDataValue() (or other functions attached to it) on the interpreter or in another function, python crashes. In readFile1 function, out.GetNoDataValue() return no data value of the band successfully. When you return the band like in readFile2, you can not do anything with it. When you do, python crashes.

my gdal version is '1100000' (gdal.VersionInfo()) My operating system us ubuntu 12.04 LTS

I think this could be a bug in gdal, I am not sure about it.

from osgeo import gdal def readFile1(inputFile,variableNo,bandNo): filereadtemp=gdal.Open(inputFile) fileread=gdal.Open(filereadtemp.GetSubDatasets()[variableNo][0]) out=fileread.GetRasterBand(bandNo) nodatavalue=out.GetNoDataValue() return nodatavalue def readFile2(inputFile,variableNo,bandNo): filereadtemp=gdal.Open(inputFile) fileread=gdal.Open(filereadtemp.GetSubDatasets()[variableNo][0]) out=fileread.GetRasterBand(bandNo) return out

أكثر...
 
أعلى