<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hi there everybody,<br>
<br>
I want to derive some floating point values using an expression in
the<br>
field calculator (see model snapshot below). I'm using qgis
3.10.6 on<br>
Debian 10.<br>
<br>
I am finding that the first field calculator call, which produces
'dbgfieldcalc',<br>
gives only NULL answers.<br>
<br>
The second field calculator call (at the bottom, which produces
'dbgfishnetFinal')<br>
does almost the same thing and it works great.<br>
<br>
At no time will running this model produce errors. In fact, even<br>
changing attribute names to be invalid attribute names doesn't
produce<br>
an error at all.<br>
<br>
What I expect:<br>
- That the field calculator is able to consistently run simple
expressions through.<br>
- That feeding invalid attribute names causes an error report and
aborts the model run.<br>
<br>
I've read through the docs that show up for a search on "qgis-user
field calculator".<br>
<br>
The python code produced for this model reads<br>
: # Field
calculator
<br>
: alg_params =
{
<br>
: 'FIELD_LENGTH':
10,
<br>
: 'FIELD_NAME':
'emissionsAfterFishnetInGramPerHour',
<br>
: 'FIELD_PRECISION':
3,
<br>
: 'FIELD_TYPE':
0,
<br>
: 'FORMULA': 'attribute($currentfeature,
\'emissionsingramsperhour\') * attribute($currentfeature,
\'xlength_2\') / attribute($currentfeature,
\'length\')', <br>
: 'INPUT':
outputs['AddGeometryAttributes']['OUTPUT'],
<br>
: 'NEW_FIELD':
True,
<br>
: 'OUTPUT':
parameters['Dbgfieldcalc']
<br>
:
}
<br>
: outputs['FieldCalculator'] =
processing.run('qgis:fieldcalculator', alg_params,
context=context, feedback=feedback,
is_child_algorithm=True)
<br>
: results['Dbgfieldcalc'] =
outputs['FieldCalculator']['OUTPUT']
<br>
where "xlength_2" is a nonexistent attribute (but the script has
the same behavior when I use<br>
"length_2", which is an existent attribute).<br>
<br>
Is it usual to not detect errors like this? Is there some reason
the expression I<br>
wrote (with the proper attribute name) wouldn't give a floating
point number, but produces NULL instead?<br>
<br>
many thanks,<br>
James P.</p>
<p><br>
</p>
<p>snapshot:</p>
<p><img src="cid:part1.78E56FDB.74414BF6@pdx.edu" alt=""></p>
<pre class="moz-signature" cols="72">--
James E. Powell, MS
Pronouns: he/him/his
Applied Physics PhD Candidate
Department of Physics
Portland State University
Home page: <a class="moz-txt-link-freetext" href="http://web.pdx.edu/~powellj">http://web.pdx.edu/~powellj</a>
Office: SRTC 409B Phone: +1-503-725-8515
</pre>
</body>
</html>