Subtracting average values from grid file with grdmath

Hi all,

I am new to GMT and I have been using GMTSAR to create deformation maps. But extracting deformation from an area depends on having a stable reference point to estimate relative velocity in respect to that reference point.

I have a file called unwrap_ll.grd, which is in lat/lon coordinates. I am trying to select a stable reference area in this file and then subtract the average z value of that stable area from the original unwrap_ll.grd file. To do this I did the following steps:

  1. Used grdcut to cut out the stable reference area:
    gmt grdcut unwrap_ll.grd -Gref_area_ll.grd -R174.7825/174.7875/-36.82771/-36.824265 -V

  2. Used grdinfo to extract the average z value of the stable reference area:
    gmt grdinfo ref_area_ll.grd -L2
    (average z value is -0.64)

  3. Used grdmath to subtract the average value of the ref_area_ll.grd file from the original unwrapped_ll.grd file:
    gmt grdmath -0.64 unwrap_ll.grd SUB = unwrap_ref_ll.grd

I am not sure if I have done the final step correctly. When I compare the unwrap_ll.grd and unwrap_ref_ll.grd the values seem to be the opposite. Like the unwrap_ref_ll.grd has been inverted. Can anyone see where I am going wrong? I have attached images of the unwrap_ll and unwrap_ref_ll as an example.

I hope this made sense!



Hi Matt, you are subtracting your grid from -0.64 instead of the other way around (switch their order in the grdmath call).

Ahh yes I see. Thank you so much!