saga_api python库:引发AttributeError(“没有构造函数定义”)

loading...


0

我'm trying to execute a python script using saga_api library, unfortunately I' m在第一步停止:( . 当我托盘在python上执行此命令时: aga_api.CSG_Module_Library() 我有这样的错误消息:

def init(self, args, *kwargs):
    raise AttributeError("No constructor defined")
        AttributeError: No constructor defined

它在窗户上的剂量相同!

请你帮助我绕过这一步吗?

System : Ubuntu 13.10 x64
python version : 2.7.5+
saga_api library version : 2.1.1
SAGA program version : 2.1.1
swig version : 2.0.10

这是代码:

!/ usr / bin / env python

import saga_api,sys,os

def import_raster(in__grid):

print saga_api.SAGA_API_Get_Version()

fmlb = '/usr/lib/saga/libio_gdal.so'

Library = saga_api.CSG_Module_Library() # here is the bug !!!

if Library.Create(saga_api.CSG_String(fmlb)) == 0:
    print 'unable to load SAGA module library'
    return 0

print '... success'

Module = Library.Get_Module('GDAL: Import Raster')

Parms = Module.Get_Parameters()
Parms('FILES').Set_Value(in__grid) 
Parms('SELECT').Set_Value(1) 
Parms('TRANSFORM').Set_Value(0)
Parms('INTERPOL').Set_Value(0)

Parms = Module.Get_Parameters(0) # additional parameter list

print Module.Get_Name() + ': ' + Parms('FILE').asString()

if Module.Execute() == 0:
    print 'module execution failed'
    return 0
print 'module successfully executed'

print 'save as SAGA grid'
if Parms('GRID').asGrid().Save(saga_api.CSG_String(in__grid)) == 0:
    print '... failed'
    return 0
print '... success'

return 1

如果 name ==' main ':

if len( sys.argv ) != 4:
    print 'Usage: this_script.py <in: gridfile> <out: gridfile> <in: shapefile> <out: shapefile>'
    in__grid = '/home/.../CC432_landsat8.tif'
    in__grid = os.path.abspath(in__grid)

else:
    in__grid = sys.argv[1]

    if os.path.split(in__grid)[0] == '':
        in__grid    = './' + in__grid

Import_raster(in__grid)

打印“完成!”

这是init:.... class CSG_Module_Library(_object): swig_setmethods = {} setattr = lambda self,name,value:_swig_setattr(self,CSG_Module_Library,name,value) swig_getmethods = {} getattr = lambda self,name:_swig_getattr (self,CSG_Module_Library,name)def init (self,* args,** kwargs):raise AttributeError("No constructor defined") repr = _swig_repr def is_Valid(self):return _saga_api.CSG_Module_Library_is_Valid(self)def Get_File_Name(self):return _saga_api . CSG_Module_Library_Get_File_Name(self)def Get_Library_Name(self):return _saga_api.CSG_Module_Library_Get_Library_Name(self)def Get_Info(self,* args):return _saga_api.CSG_Module_Library_Get_Info(self,* args)def Get_Name(self):return _saga_api.CSG_Module_Library_Get_Name(self)def Get_Description(self):return _saga_api.CSG_Module_Library_Get_Description(self)def Get_Author(self):return _saga_api.CSG_Module_Library_Get_Author(self)def Get_Version(self):return _saga_api.CSG_Module_Library_Get_Version(self)def Get_Sum mary(self,* args):return _saga_api.CSG_Module_Library_Get_Summary(self,* args)def Get_Count(self):return _saga_api.CSG_Module_Library_Get_Count(self)def Get_Menu(self,* args):return _saga_api.CSG_Module_Library_Get_Menu(self,* args) def Get_Module(self,* args):return _saga_api.CSG_Module_Library_Get_Module(self,* args)def Get_Module_Grid(self,* args):return _saga_api.CSG_Module_Library_Get_Module_Grid(self,* args)def Get_Module_Interactive(self,* args):return _saga_api . CSG_Module_Library_Get_Module_Interactive(self,* args)def Get_Module_Grid_Interactive(self,* args):return _saga_api.CSG_Module_Library_Get_Module_Grid_Interactive(self,* args)CSG_Module_Library_swigregister = _saga_api.CSG_Module_Library_swigregister CSG_Module_Library_swigregister(CSG_Module_Library)....

0回答

No Data

loading...

评论

暂时没有评论!