title: Stiching together topographic profiles based on known overlap
body: <p>I have a series of topographic profile scans that I would like to combine to create a single continuous profile. The only issue is that each scan may or may not have been taken from a different height, so while the different files have a fair amount of overlap in terms of the area covered, the different data may not have a common reference point in terms of absolute height. </p>
  
  <p>Below are 4 different scans. Each scan contains approximately 30  measurements, with the last few measurements representing new data, and the rest being overlap with the previous scan. The first scan contains the only known absolute values, so the first scan is the "gold standard". The second scan happens to be taken from the same height, so the overlap matches up (almost) perfectly and only adds 4 new points to the previous scan. The third and fourth scans are taken from different heights, so while the overlap covers the same area (relatively), I can not simply stitch it onto the previous two scans. </p>
  
  <pre><code>   Scan1&lt;-c(5,6,7,8,15,16,18,20,25,23,20,17,15,10,10,9,8,9,11,10,13,16,17,19,20,25,28,30,29,30)
     Scan2&lt;-c(15,16,18,20,25,23,20,16,15,10,10,9,8,9,11,10,13,16,17,19,20,25,28,30,29,30,32,35,38,37)
     Scan3&lt;-c(28,25,23,18,18,17,16,17,19,18,21,23,25,27,26,33,36,37,37,38,40,43,46,45,43,42,40,38,32,30)
     Scan4&lt;-c(27,30,29,36,39,39,40,41,43,46,49,48,46,45,43,41,35,33,30,29,28,30,31,32,35)
  </code></pre>
  
  <p>Using R, is there a way to stitch these 4 scans together to make a continuous topographic profile? The absolute height would need to be based off of the first scan, with each successive scan being stitched onto the previous scan. IE- Scan2 is stitched onto Scan 1 adding 4 data points, then the new data from Scan 3 is added onto to the combination of Scan1 and Scan2, then the new data from Scan4 is added onto the combination of Scans 1,2, and 3, and so on....</p>
  
  <p>I'm assuming there is a way to normalize all the data by matching up the large overlap between scans, using some sort of pattern recognition to figure out that Scan3 is about 8 units different from Scan1, and that Scan4 is about 11 units off. But please note there is some "noise" in my data and the pattern of overlap will not be a perfect fit.</p>
  
  <p>The end result should contain a complete topographic profile encompassing all 4 scans, with some sort of adjustments for when the actual numbers differ. Something along the lines of:</p>
  
  <pre><code>5,6,7,8,15,16,18,20,25,23,20,16.5,15,10,10,9,8,9,11,10,13,15.5,17,19,19,25,28,29.5,29,30,32,35,38,37,35,34,32,30,24,22,19,18,17,19,20,21,24    
  </code></pre>