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?
2 Answers
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 :)– JohnGISCommented 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
else:
return n
bottom window
values(!FIELDNAME1!)