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 '15 at 9:23

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 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, privacy policy and cookie policy

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