[Qgis-developer] Re: [SoC] Re: SAGA Interface for QGIS - Weekly report

Martin Dobias wonder.sk at gmail.com
Wed Aug 17 05:14:56 EDT 2011


Hi Camilo

On Mon, Aug 15, 2011 at 6:43 PM, Camilo Polymeris <cpolymeris at gmail.com> wrote:
> Hello
>
> This week I have implemented Range parameters and tried to implemented
> the SAGA's raster output. To do this I have tried to solve various
> issues, mostly regarding specifying grid systems to the module. I have
> implemented a widget that allows the user to set a custom grid system
> and mechanisms to take the grid system from the input grids. The
> efforts haven't been enough, tough, SAGA modules keep outputting
> invalid rasters. A discussion concerning this issue is going on at the
> saga-gis-developer mailing list[1]. I hope that with a little help
> I'll be able to solve this during this week.

Looking further into saga api I have finally a bit clearer idea of
what is happening there.

There are "modules" and "grid modules". Interactive modules are not
interesting for us right now. Grid modules are an extension of normal
modules - they have a global grid system. Grid system basically means
size of the grids. Grid system is used to enforce that input/output
layers have the same dimensions so that the modules do not have to
handle their compatibility by themselves.

Interesting parameters:
1. CSG_Parameter_Data_Output. Used e.g. in import modules. This
parameter does not carry any input data and is not shown in saga gui
in module's properties - it is strictly for output. Its
Get_DataObject_Type() method determines whether it will contain a
grid, shapes or some other object. saga only sets a special value
DATAOBJECT_CREATE as its value before executing a module.
2. CSG_Parameter_Grid: Used widely for both input and output. By
default this parameter is grid system dependent, that means it must be
compatible with module's global grid system. This parameter has always
a grid system as a parent (the parent grid system is implicitly
created for the parameter if there isn't one). When the parameter is
for input, a grid should be created and loaded with data (with
compatible grid system). When the parameter is for output, an empty
grid instance can be passed - alternatively an existing grid may be
passed which will be overwritten.

Typically a grid module has one or more input and output grids - they
have a common (module's global) grid system.

Camilo: if you still struggle with invalid raster output then try to
pick a module and create a small python script that sets its
parameters, executes the module and saves the output - without
anything QGIS specific. Such a script may help you to understand the
semantics of saga api and if problems persists it is easier to post
such a script to saga-gis-devel list for help than pointing to
qgis-specific implementation where it is not completely clear what is
set and what is not.


> In case you are interested in testing the --still very experimental--
> project, a short document explaining installation and basic usage is
> now available through the wiki[3].

I have tried "lectures/01: my first module" and while it says that the
module execution succeeded, it complains that
"/tmp/saga-qgis96159568.sgrd is not a valid or recognized raster data
source". Indeed that file does not exist.


Then I wanted to load some grids... loading from GDAL requires data
object list, so I took a simpler module: "import from image". However
it also leads to errors:

1. error when opening the module:

Traceback (most recent call last):
  File "/home/martin/.qgis/python/plugins/processingplugin/panel.py",
line 82, in onItemActivated
    dialog = Dialog(self._iface, item.module())
  File "/home/martin/.qgis/python/plugins/processingplugin/dialog.py",
line 48, in __init__
    self.rebuildDialog()
  File "/home/martin/.qgis/python/plugins/processingplugin/dialog.py",
line 63, in rebuildDialog
    for param, value in self.moduleinstance.parameters().items():
  File "/home/martin/qgis/inst-master/share/qgis/python/processing/moduleinstance.py",
line 49, in parameters
    self.module().parameters()]
  File "/home/martin/.qgis/python/plugins/saga/plugin.py", line 240,
in parameters
    self.addParameter(params.Get_Parameter(j))
  File "/home/martin/.qgis/python/plugins/saga/plugin.py", line 167,
in addParameter
    qgisParam.setValue(0)
AttributeError: ChoiceParameter instance has no attribute 'setValue'

I have solved that by removing the line where setValue() is called on
a parameter.

2. an error when chosen an input image file:

Traceback (most recent call last):
  File "/home/martin/.qgis/python/plugins/saga/plugin.py", line 204, in
    lambda x: self.onParameterChanged(qgisParam, sagaParam, x))
  File "/home/martin/.qgis/python/plugins/saga/plugin.py", line 229,
in onParameterChanged
    sagaParam.Set_Value(value)
  File "/home/martin/inst/saga-bin/lib/python2.7/site-packages/saga_api.py",
line 3895, in Set_Value
    def Set_Value(self, *args): return
_saga_api.CSG_Parameter_Set_Value(self, *args)
NotImplementedError: Wrong number of arguments for overloaded function
'CSG_Parameter_Set_Value'.
  Possible C/C++ prototypes are:
    Set_Value(CSG_Parameter *,int)
    Set_Value(CSG_Parameter *,double)
    Set_Value(CSG_Parameter *,void *)
    Set_Value(CSG_Parameter *,wchar_t const *)

It helped to handle PathParameter in the same way as StringParameter.

3. error executing the module. Even if the module execution succeeded
the output data object(s) would not be saved or imported to qgis
because it does not provide support for data object output parameters.

Martin


More information about the Qgis-developer mailing list