1

I have used an equation within the field calculator, that has previously worked in an older version of QGIS, I am currently using QGIS 3.6.2 the equation being:

(atan((xat(-1)-xat(0))/(yat(-1)-yat(0)))) * 180/3.14159 + (180 *(((yat(-1)-yat(0)) < 0) + (((xat(-1)-xat(0)) < 0 AND (yat(-1) - yat(0)) >0)*2)))

This is the answer found on a previous question within this forum that helped me to achieve the angle of each line within a layer. However I keep getting the error evaluation message using the newer version of QGIS saying...

An error occurred while evaluating the calculation string: Cannot convert 'inf' to double.

What does this mean?

  • 1
    Try changing your syntax to $y_at(i) and $x_at(i) – HDunn May 4 at 17:20
  • Once you get the function to work, please add an update to the question where you found the original expression. Don't delete the original, just add the updated version, with a note that it works in QGIS 3, whereas the other one uses older syntax (probably from QGIS 2). This will really help other users of this site. – csk May 4 at 17:46
  • @HDunn is right, have a look at Geometry Functions chapter in docs: docs.qgis.org/3.4/en/docs/user_manual/working_with_vector/… – TomazicM May 4 at 18:08
  • Im really sorry how would I change the syntax what would the change be I changed it as below: (atan(($xat(-1)-$xat(0))/($yat(-1)-$yat(0)))) * 180/3.14159 + (180 *((($yat(-1)-$yat(0)) < 0) + ((($xat(-1)-$xat(0)) < 0 AND ($yat(-1) - $yat(0)) >0)*2)))- However there was a syntax error so it wouldn't accept it – Alison Jones May 4 at 19:31
  • 1
    @AlisonJones perhaps you should elaborate your question to include what you are trying to achieve and what layer are you trying to work on. If you expression has operators like > and <, is this a snippet from a larger conditional statement? You need to help us help you – HDunn May 5 at 9:02

Your Answer

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

Browse other questions tagged or ask your own question.