# How to find minimum and maximum z within a bin, keeping the true position

Hi,

I have for another project been using the Blockmedian and the -Q parameter to find the median value for each bin, in their true positions, and it works fairly well.

In another project I need to find the minimum and maximum z values in their true positions, but cannot find a simple way to do that using GMT.

If I use the Blockmedian, Blockmean, or Blockmode I can get the min and max values for the bins, but not for their true position.

As an example “blockmode TestklippWGS.txt -I15s -R17:18E/18:52E/58:00N/58:38N -r -E >test1_4_r_Detailed.txt”
gives me the output: X, Y Z Sdev Min Max: 17.497264016 58.6264356965 -38.7 3.7065 -41.2 -36.2 but only for the cell node position.

Anyone that has a simple solution to get min and max values within a bin in true position?

Regards,
Hans

Have you tried blockmedian -Q0 to report the 0 percentile (i.e., the min) and see if that yields its coordinates? Same for -Q100, and would have to be two separate calls.

I cannot see that there is a possibility to add a parameter “0” to the switch “-Q” in the man pages.
However I tried it and it runs without any alerts, The outcome however is identical regardless if I use -Q or -Q0.
I though now saw that it might be possible to use the “Blockmedian -Q” and add “-T” that gives me another output, however it is impossible to set the value to “0” so I used "“Blockmedian -Q -T0.01” and it seems to give me the minimum values

I will make some further tests to check if I really got the minimum depths in their true positions. I will comment again when I have doublechecked.

Regards,
Hans

Sorry, I meant -T to set which quantile you wanted (0 vs 100).

@pwessel I can now confirm that:

“-Q -T0.001” Provides minimum value in true position
" -Q -T0.999" Provides maximum value in true position
“-Q” OR “-Q -T0.5” Provides statistical median in true position, if the number of points in the cell is odd otherwise average xyz of the two middle values
“-T0.5” Provides statistical median in (what seems to be) a median calculated position of all points in the cell.

In the attached image black crosses are input data, red and green dots are min and max values, blue diamond is median value in true position and yellow triangle is median value in median positions.

Another question that comes to mind is if there is any possibility to set a switch to force “blockmedian-Q” to select the smaller or larger of the two values if there is a tie (even number of samples)? That would give a small shallow or deep bias to a bathymetric dataset, but still only select from true measured points in their true positions. I can see that for the switch " -E r | s [ - ] there is a possibility to select if the record number should origin from the low or high value, if there is a tie.

Thanks again for the help

Hans

I suggest you open a feature request on GitHub so it can be tracked.

1 Like

A quick note. You can post images here just with a drag-n-drop

1 Like

Thanks, I didn’t realize that it should make any difference
I edited the post now so that the image appears in the post itself.

//Hans

I just found out in GitHub that there were changes made to facilitate my request to be able to get a high or low biased median when there is a Tie due to an even number of datapoints in a cell.

Looking forward to try it out, and it will increase the quality of my results.
I dont have time right now to make a full test, but will try to report back at a later time.

Until then, Thanks !

1 Like