Hi there everybody,

I want to derive some floating point values using an expression in the
field calculator (see model snapshot below).  I'm using qgis 3.10.6 on
Debian 10.

I am finding that the first field calculator call, which produces 'dbgfieldcalc',
gives only NULL answers.

The second field calculator call (at the bottom, which produces 'dbgfishnetFinal')
does almost the same thing and it works great.

At no time will running this model produce errors.  In fact, even
changing attribute names to be invalid attribute names doesn't produce
an error at all.

What I expect:
- That the field calculator is able to consistently run simple expressions through. - That feeding invalid attribute names causes an error report and aborts the model run.

I've read through the docs that show up for a search on "qgis-user field calculator".

The python code produced for this model reads
:  # Field calculator
:         alg_params = {
:             'FIELD_LENGTH': 10,
:             'FIELD_NAME': 'emissionsAfterFishnetInGramPerHour',
:             'FIELD_PRECISION': 3,
:             'FIELD_TYPE': 0,
:             'FORMULA': 'attribute($currentfeature, \'emissionsingramsperhour\') * attribute($currentfeature, \'xlength_2\') / attribute($currentfeature, \'length\')',
:             'INPUT': outputs['AddGeometryAttributes']['OUTPUT'],
:             'NEW_FIELD': True,
:             'OUTPUT': parameters['Dbgfieldcalc']
: }
:         outputs['FieldCalculator'] = processing.run('qgis:fieldcalculator', alg_params, context=context, feedback=feedback, is_child_algorithm=True)
:         results['Dbgfieldcalc'] = outputs['FieldCalculator']['OUTPUT']
where "xlength_2" is a nonexistent attribute (but the script has the same behavior when I use
"length_2", which is an existent attribute).

Is it usual to not detect errors like this?  Is there some reason the expression I wrote (with the proper attribute name) wouldn't give a floating point number, but produces NULL instead?

many thanks,
  James P.


snapshot:

--
James E. Powell, MS
Pronouns: he/him/his
Applied Physics PhD Candidate
Department of Physics
Portland State University
Home page: http://web.pdx.edu/~powellj
Office: SRTC 409B Phone: +1-503-725-8515

_______________________________________________
Qgis-user mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to