# How to Merge avoiding gaps

**URL:** <https://discourse.obspy.org/t/how-to-merge-avoiding-gaps/900>\
**Category:** Users Mailing List Archive\
**Tags:** archive\
**Created:** [June 4, 2020, 7:22pm UTC](https://discourse.obspy.org/t/how-to-merge-avoiding-gaps/900 "2020-06-04T19:22:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Juan\_Manuel\_Solano\_F](https://discourse.obspy.org/letter_avatar_proxy/v4/letter/j/ea666f/32.png) [@Juan\_Manuel\_Solano\_F](https://discourse.obspy.org/u/Juan_Manuel_Solano_F)\
**Post date:** [June 4, 2020, 7:22pm UTC](https://discourse.obspy.org/t/how-to-merge-avoiding-gaps/900/1 "2020-06-04T19:22:46Z")

</div>

Hello everyone,

I want to avoid gaps when merging data, I just want to merge overlaps to become one trace (with method 1, trusting the recent data). The traces that are not overlapping must remain as separated traces.

I read Merge and \__add_ documentation and it does not seem to be possible to merge only overlaps.

Can some one help me?

Thank you!

Juan Manuel

---

<div class="post-metadata">

**Author:** ![megies](https://discourse.obspy.org/user_avatar/discourse.obspy.org/megies/32/9_2.png) [@megies](https://discourse.obspy.org/u/megies)\
**Post date:** [June 5, 2020, 8:09am UTC](https://discourse.obspy.org/t/how-to-merge-avoiding-gaps/900/2 "2020-06-05T08:09:03Z")

</div>

It is not 100% clear to me what exactly you expect in all the possible  
ways that data can overlap, but if you look at the docs for Stream.merge..

> **[obspy.core.stream.Stream.merge — ObsPy 1.4.2 documentation](https://docs.obspy.org/packages/autogen/obspy.core.stream.Stream.merge.html?highlight=merge)**

..and follow the link to description of cleanup merge (method=-1), that  
seems to sound like what you want.

[https://docs.obspy.org/packages/autogen/obspy.core.stream.Stream.\_cleanup.html](https://docs.obspy.org/packages/autogen/obspy.core.stream.Stream._cleanup.html)

best,
