# Select -Z option

**URL:** <https://forum.generic-mapping-tools.org/t/select-z-option/4763>\
**Category:** Q&A\
**Created:** [April 2, 2024, 4:04pm UTC](https://forum.generic-mapping-tools.org/t/select-z-option/4763 "2024-04-02T16:04:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Geodesy](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/john_geodesy/32/116_2.png) [@John\_Geodesy](https://forum.generic-mapping-tools.org/u/John_Geodesy)\
**Post date:** [April 2, 2024, 4:04pm UTC](https://forum.generic-mapping-tools.org/t/select-z-option/4763/1 "2024-04-02T16:04:03Z")

</div>

Simple question, hope there is a simple answer.

In the select command, -Z will select a range of values: -Zmin/max. What exactly is the selection criteria? is it

1. min \< val \< max?
2. min \< val ≤ max?
3. min ≤ val \< max?
4. min ≤ val ≤ max?

My guess is that it is answer 4.

I suggest that more control be available to the user for the -Z command, perhaps as an option to utilize any of the 4 criteria above. In other words, to specify how the range is defined.

Currently, when parsing data over range levels, data situated exactly on a boundary can get placed into two adjacent ranges.

As a work around, the user has to artificially set their bounding values. Not a bad situation, but the user needs to be made aware of the particulars of what defines a “range of values” within GMT.

---

<div class="post-metadata">

**Author:** ![jjg](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/jjg/32/2822_2.png) [@jjg](https://forum.generic-mapping-tools.org/u/jjg)\
**Post date:** [April 2, 2024, 4:40pm UTC](https://forum.generic-mapping-tools.org/t/select-z-option/4763/2 "2024-04-02T16:40:42Z")

</div>

[Looks like](https://github.com/GenericMappingTools/gmt/blob/master/src/grdcut.c#L603) it is your option (4).

---

<div class="post-metadata">

**Author:** ![Esteban82](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/esteban82/32/54_2.png) [@Esteban82](https://forum.generic-mapping-tools.org/u/Esteban82)\
**Post date:** [April 3, 2024, 11:56am UTC](https://forum.generic-mapping-tools.org/t/select-z-option/4763/3 "2024-04-03T11:56:30Z")

</div>

> [@John\_Geodesy](#):
>
> I suggest that more control be available to the user for the -Z command, perhaps as an option to utilize any of the 4 criteria above. In other words, to specify how the range is defined.

I agree that the way of defining the ranks could be improved.

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [April 3, 2024, 2:44pm UTC](https://forum.generic-mapping-tools.org/t/select-z-option/4763/4 "2024-04-03T14:44:33Z")

</div>

While I understand that for long time users adding one more flag to account for a very specific need may look the way to go, that, from all our sadness, will not continue to happen. Specific operations commonly used in programing languages should use … programming languages.

As an example, in Julia the ´\>=´ would be done as (and please, don’t tell it’s harder to do=

```auto
julia> xyz = rand(100,3);

julia> gmtselect(xyz, Z=(0.4,0.6))
BoundingBox: [0.030929929103599263, 0.9623095989851388, 0.013467113385888685, 0.9479798746333762, 0.4105386373773122, 0.5865967124620851]

21×3 GMTdataset{Float64, 2}
 Row │ col.1 col.2 col.3
─────┼────────────────────────────────
   1 │ 0.045983 0.313799 0.5243
   2 │ 0.953737 0.755524 0.420566
   3 │ 0.758531 0.922908 0.566729
   4 │ 0.0548685 0.479421 0.582389
   5 │ 0.174204 0.614245 0.576895
   6 │ 0.321263 0.605617 0.4883
   7 │ 0.96231 0.94798 0.518068
   8 │ 0.769331 0.261765 0.434375
   9 │ 0.961621 0.0766911 0.586597
  10 │ 0.536337 0.0134671 0.454094
  11 │ 0.0309299 0.441652 0.535651
  12 │ 0.675437 0.0334161 0.548987
  13 │ 0.151107 0.197887 0.567909
  14 │ 0.30619 0.534885 0.410539
  15 │ 0.69253 0.0290365 0.548246
  16 │ 0.407515 0.671637 0.54927
  17 │ 0.12757 0.319798 0.574274
  18 │ 0.34365 0.460857 0.505948
  19 │ 0.436706 0.29054 0.541065
  20 │ 0.538692 0.664721 0.482972
  21 │ 0.475629 0.893896 0.548435

```

Now, with a jl command

```auto
julia> xyz[0.4 .< xyz[:,3] .< 0.6, :]
21×3 Matrix{Float64}:
 0.045983 0.313799 0.5243
 0.953737 0.755524 0.420566
 0.758531 0.922908 0.566729
 0.0548685 0.479421 0.582389
 0.174204 0.614245 0.576895
 0.321263 0.605617 0.4883
 0.96231 0.94798 0.518068
 0.769331 0.261765 0.434375
 0.961621 0.0766911 0.586597
 0.536337 0.0134671 0.454094
 0.0309299 0.441652 0.535651
 0.675437 0.0334161 0.548987
 0.151107 0.197887 0.567909
 0.30619 0.534885 0.410539
 0.69253 0.0290365 0.548246
 0.407515 0.671637 0.54927
 0.12757 0.319798 0.574274
 0.34365 0.460857 0.505948
 0.436706 0.29054 0.541065
 0.538692 0.664721 0.482972
 0.475629 0.893896 0.548435

```
