# Sample1d: don't eliminate duplicate values

**URL:** <https://forum.generic-mapping-tools.org/t/sample1d-dont-eliminate-duplicate-values/1976>\
**Category:** Q&A\
**Tags:** gmt\
**Created:** [August 11, 2021, 6:50am UTC](https://forum.generic-mapping-tools.org/t/sample1d-dont-eliminate-duplicate-values/1976 "2021-08-11T06:50:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mjh217](https://avatars.discourse-cdn.com/v4/letter/m/bc8723/32.png) [@mjh217](https://forum.generic-mapping-tools.org/u/mjh217)\
**Post date:** [August 11, 2021, 6:50am UTC](https://forum.generic-mapping-tools.org/t/sample1d-dont-eliminate-duplicate-values/1976/1 "2021-08-11T06:50:10Z")

</div>

Hi all,

I recently updated to gmt 6.2.0 from 6.1.0 and am having trouble with one of the updates to sample1d. Originally, if I had a look-up table (lookup.xy) like this:

0 00  
1 10  
2 20

And sampled it at these points (sample.x):

0.5  
1.5  
1.9  
1.5

Using “gmt sample1d -Fl -Tsample.x lookup.xy” would return:

0.5 5  
1.5 15  
1.9 19  
1.5 15

But the updated version gives:

sample1d [WARNING]: Eliminated 1 duplicate values from the sorted array  
0.5 5  
1.5 15  
1.9 19

I understand from this thread ([Sample1d on gmt6.1 and gmt6.2](https://flint.soest.hawaii.edu/t/sample1d-on-gmt6-1-and-gmt6-2/830/5)) why this update was made, but is there a way to not skip the duplicates? Often I am stripping columns from a data file, using sample1d to find a corresponding value, and pasting things back together, which now doesn’t work when there happen to be duplicate values due to the rows no longer corresponding. Or am I using the wrong tool for the job?

Also, has a sorting procedure been added, such that the points are not necessarily returned in their original order?

Thanks a lot for your help!

---

<div class="post-metadata">

**Author:** ![pwessel](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pwessel/32/30_2.png) [@pwessel](https://forum.generic-mapping-tools.org/u/pwessel)\
**Post date:** [August 12, 2021, 2:09am UTC](https://forum.generic-mapping-tools.org/t/sample1d-dont-eliminate-duplicate-values/1976/2 "2021-08-12T02:09:44Z")

</div>

Hm, yes I agree there really should not be any reason to ban duplicate points given via -T. Once the spline is defined by lookup.xy then you should be able to sample at any value and repeatedly. So not quite what the other thread was all about but I will need to check things as I do not want to break something we have fixed. I will have a look.

---

<div class="post-metadata">

**Author:** ![mjh217](https://avatars.discourse-cdn.com/v4/letter/m/bc8723/32.png) [@mjh217](https://forum.generic-mapping-tools.org/u/mjh217)\
**Post date:** [April 7, 2022, 3:14am UTC](https://forum.generic-mapping-tools.org/t/sample1d-dont-eliminate-duplicate-values/1976/3 "2022-04-07T03:14:56Z")

</div>

Hi Paul,

I was just wondering if this got fixed at some point? Or whether anyone came up with a workaround? I tried it in 6.3.0 with the same result.

Cheers!

---

<div class="post-metadata">

**Author:** ![pwessel](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pwessel/32/30_2.png) [@pwessel](https://forum.generic-mapping-tools.org/u/pwessel)\
**Post date:** [April 7, 2022, 9:00am UTC](https://forum.generic-mapping-tools.org/t/sample1d-dont-eliminate-duplicate-values/1976/4 "2022-04-07T09:00:17Z")

</div>

Works fine in master so either build from github or wait for 6.4 (\< 1 month):

```
gmt sample1d -Fl -Tlookup.xy sample.x
0.5 5
1.5 15
1.9 19
1.5 15
```

---

<div class="post-metadata">

**Author:** ![mjh217](https://avatars.discourse-cdn.com/v4/letter/m/bc8723/32.png) [@mjh217](https://forum.generic-mapping-tools.org/u/mjh217)\
**Post date:** [April 7, 2022, 9:46pm UTC](https://forum.generic-mapping-tools.org/t/sample1d-dont-eliminate-duplicate-values/1976/5 "2022-04-07T21:46:41Z")

</div>

Thanks a lot! Much appreciated
