1

I have the following cases where I would like to 1. Determine if a feature has a lower elevation than another and is on the same line feature. If it is then call it 'dwn_cross'. 2. If a feature has a lower elevation than another, isn't on the same feature line, and the the azimuths of the first feature are within 120 degrees of the second feature then it is also 'dwn_cross'.

CASE 
    WHEN ("pipe_elev1" > "rd_elev1" AND "p_LNRFTRD" = "LNRFTRD") THEN 'dwn_cross'
    WHEN "pipe_elev1" > "rd_elev1" AND  "p_LNRFTRD" != "LNRFTRD" AND "p_azi" >= "rd_azi" - 120 AND "p_azi" <= "rd_azi" + 120 AND "Distance" = minimum("Distance","pipecr_no") THEN 'dwn_cross'
    END

I get the following 'expression invalid' error:

Parser Errors: syntax error, unexpected NAME syntax error, unexpected QUOTED_COLUMN_REF, expecting $end syntax error, unexpected NAME, expecting $end syntax error, unexpected QUOTED_COLUMN_REF, expecting $end syntax error, unexpected NAME, expecting $end syntax error, unexpected QUOTED_COLUMN_REF, expecting $end syntax error, unexpected NAME, expecting $end syntax error, unexpected QUOTED_COLUMN_REF, expecting $end syntax error, unexpected NAME, expecting $end syntax error, unexpected QUOTED_COLUMN_REF, expecting $end

Can't figure out what is wrong.

1
  • A stab in the dark: your description speaks about multiple features, in particular lines and pipes. Do you truly have all those fields as attributes in one layer? If not, you will need to tell QGIS how they are related, either via Relations or via Joins.
    – Houska
    Jul 2, 2021 at 12:42

1 Answer 1

1

The syntax of your expression is correct. For me it works fine. However, it seems that you don't have all field-names you use in your expression or that they are mis-spelled. You should have the following 7 field-names correctly spelled:

Distance, LNRFTRD, p_LNRFTRD, p_azi, pipe_elev1, rd_azi, rd_elev1

You can use the following expression to generate a list in string-format of all your attribute names to check it:

array_to_string (map_akeys( attributes( ) ))

Screenshot: I copied your expression to the field calculator. As you see in the preview, a correct output is generated:

enter image description here

2
  • I am unsure how to implement the array_to_string (map_akeys( attributes( ) ))
    – MJM
    Jul 2, 2021 at 17:01
  • 1
    create a new field with field calculator, define it as text field and set field length long enougu (no. of characters long enough for all fieldnames) , than insert the expression array_to_string (map_akeys( attributes( ) )) in the place that is highlighted in yellow above. But you don't need that, it's just for control. In your expression, just make sure that all fieldnames are correctly spelled, than it should work
    – Babel
    Jul 2, 2021 at 17:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.