I have a data set as below which includes the IDs for segments, their ranges coordinates (start & end), the length of the segment and the traffic load on that part of the segment. A specific segment might have several records and ranges which might overlap with each other. A data sample of my input is as below:
I need to remove these overlaps from the ranges by making smaller segments based on each ID and providing the new segment ranges for an ID which has no overlap with each other. In the meanwhile I also need to calculate the average of the traffic load on each new segment range based on the average of the traffic load on the original segments which it belongs to. I have provided my desired output and calculations as table below.