I often need to create a single GPX file from multiple related but different GPX files from Garmin and Wikiloc. My use case is finding route recommendations for running based on GPX files. I try to get a single GPX file so I do not have to juggle multiple files during the run. Original GPX files are also noisy, so the added advantage is having a precise path to navigate instead of dealing with GPX noise.
I start by putting all downloaded GPX files into a single directory and plotting them on the map. This step allows me to see them in relation to each other and spot any outliers early. I then simplify each GPX file to reduce the number of points and match them to OSM ways. I filter the points to make them evenly spaced. Finally, I use the OSRM trip service to create a single combined GPX file, or fall back to the minimal number of split files if they cannot be merged into a single file. I plot the resulting GPX files and simplify them to reduce the point count. Now I can sync them to Garmin and use them as a kind of basemap on a device that does not support basemaps.
Of course, this only works when I know the area in advance, can find enough existing route recommendations, and there is a reasonably complete OSM map. The current pipeline is error-prone and I find myself tweaking it to make it work with any specific set of GPX files. You can try it yourself and view the complete code on GitHub: https://github.com/evgeniyarbatov/gpx-courses