I have an xyz file that I want to convert negative field values in the z column to positive values. How do I do this with field calculator?

  • Thanks that does indeed change the values to positive but what I didn't make clear was that I want to keep them as the original values but without the minus symbol (effectively multiplying all negative values by -1)
    – mtsini
    Mar 22, 2015 at 9:23

2 Answers 2


In QGIS you can use abs("fieldname") to turn them into always positive values.

  • And -abs("fieldname") to go from positive to negative which just helped me :)
    – JohnGIS
    Mar 12, 2019 at 10:03

In ArcGIS desktop you could use the following python script in the field calculator, where you would create a new field (say, FIELDNAME2) and calculate the following (where FIELDNAME1 is your original values):

Pre-Logic script

def values(n):
    if n < 0:
        return n * -1
        return n

bottom window


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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