[Qgis-user] Modeler-only tools: Calculator
Bernd Vogelgesang
bernd.vogelgesang at gmx.de
Sun Aug 9 14:03:22 PDT 2015
Am 09.08.2015, 21:35 Uhr, schrieb Blumentrath, Stefan
<Stefan.Blumentrath at nina.no>:
> Hi Bernd,
>
> From your explanation it did not become quite clear to me what you
> actually want to achieve.
Hi Stefan,
actually my post was a mixture between a rant and questions, cause I'm
really a bit pissed off that hard work can be destroyed that easily by
that function. When a function is missing, ok, thats life, and I'll try to
work around.
But when a function has a built-in self-detonator that will crunch my work
in a second, my blood-pressure is rising ...
The modeler really became a nice tool. The safety of the models could
maybe somehow enhanced. Already lost lots of models in the past, till I
got the idea to switch the model path to our cloud server which keeps some
versions which can be restored.
> My guess is that you are struggling with a similar issue which a
> colleague of mine had with the raster map calculator.
> He was wondering how to use numerical variables in the raster map
> calculator, which takes the formula only as a string argument (probably
> it is the same with the Field calculator (I am not so familiar with this
> part of QGIS)?).
>
> The, probably not very elegant, but still simple solution is to generate
> the formula in a python script in Processing, which injects your
> numerical values into the formula. E.g. like this (where "F" is the
> formula and "C" e.g. a (string) map variable you are going to use in the
> formula):
>
> ##A=number 1
> ##B=number 5
> ##F=output string
> F=str(A) + "/" + str(B) + "* C"
>
> You can then uses this Python script in your model...
>
> Hope that helps. It works at least well for the raster map calculator...
I'll give it a try.
Thanx for the hint
The rest of my rant was about how to "repair" a broken model, which
somehow seems to be impossible.
Cheers
Bernd
> Cheers,
> Stefan
>
> -----Original Message-----
> From: qgis-user-bounces at lists.osgeo.org
> [mailto:qgis-user-bounces at lists.osgeo.org] On Behalf Of Bernd Vogelgesang
> Sent: 9. august 2015 16:07
> To: qgis-user at lists.osgeo.org
> Subject: [Qgis-user] Modeler-only tools: Calculator
>
> Hi,
>
> In my search for a solution for the problem, that number input variables
> in a model can't be referred to in the field calculator (while string
> inputs, though it doesn't make any sense, can):
> 2 years old http://hub.qgis.org/issues/8743
> http://gis.stackexchange.com/q/72569
>
> I found the modeler-only tools Calculator, which indeed lists all
> numerical inputs.
>
> This tool doesn't come with any explanation besides: "You can refer to
> model values in your formula, using single-letter variables, as follows:
>
> a->Gridsize
>
> and
>
> [Enter your formula here]
>
> Ok, so when I enter a formula there, what next????
>
> When I put - a - there, cause I just want this value, and try to use - a
> - in the field calculator, it does not work.
>
> Furthermore: The formula has disappeared after reopening the function:
> http://hub.qgis.org/issues/11434#note-9
>
> It does not seem to be usable at all.
>
> And it destroyed my three-days work on a model, cause by mistake I
> entered nothing and hit ok and saved the thing, which caused a python
> error and the model can't be opend again.
>
> Only the fact that I work on a cloud where I can restore my last version
> from yesterday has saved my ass. (Working locally, the hole work
> would have been gone forever!).
>
> There seems to be no way to get rid of that function from the model
> manually in a text editor, identifying the section and removing it still
> leaves a crippled model which refuses to load.
>
> Questions:
> Is there anyone around who is able to explain me the structure of a
> model file or point to least some minimal documentation?. Why do nearly
> every manual operations on a model in an editor destroy them, and how
> can I avoid this?
>
> Does anyone know how to use this Calculator without destroying the model?
>
> Is there any workaround for referencing numerical input in the field
> calculator.
>
> Cheers
> Bernd
>
> QGIS2.8.3, Linux Mint 17
>
>
>
>
> --
> Bernd Vogelgesang
> Siedlerstraße 2
> 91083 Baiersdorf/Igelsdorf
> Tel: 09133-825374
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-user
--
Bernd Vogelgesang
Siedlerstraße 2
91083 Baiersdorf/Igelsdorf
Tel: 09133-825374
More information about the Qgis-user
mailing list