Hello,
I noticed the following issue after importing, converting, editing, and exporting GPX files: For some reason, JOSM duplicates each waypoint.
Here’s what I do:
- Open import.gpx
- In Layers, remove import.gpx
- Still in Layers, convert “Markers from import.gpx” to data layer (right-click) > Convert to data layer > Simplify
- Use lasso object to select subset of waypoints
- Add new layer through File
- Edit > Merge selection
- Export new layer as GPX
And here’s what I get in the output GPX:
node/123456
What am I doing wrong?
Thank you.
–
Edit: I confirm duplicates are added by JOSM when importing a GPX file with waypoints and converting the “Markers from” layer into a data layer: They are not in the input file from eg. OverpassTurbo. In the process, choosing “Simplify” or “Proceed without simplifying” makes no difference.
As a work-around, the following Python script removes all empty elements, ie. that contain not even a “name” sub-element, since this is how duplicates show up in the output GPX file created in JOSM:
#pip install lxml BeautifulSoup4 pathlib
from bs4 import BeautifulSoup
import pathlib
import os
import sys
arguments = len(sys.argv) - 1
if arguments != 1:
print ("Must pass one arg.")
exit()
else:
item=str(sys.argv[1])
print(f"**************** Handling {item}")
BASENAME = pathlib.Path(item).stem
EXTENSION = pathlib.Path(item).suffix
PATH=pathlib.Path(item).parent
OUTPUTFILE = f"{BASENAME}.NODUPS{EXTENSION}"
os.chdir(PATH)
soup = BeautifulSoup(open(item, 'r',encoding='utf-8'), 'xml')
for wpt in soup.find_all("wpt"):
if not wpt.find("name"):
lat,lon = wpt.attrs.get('lat'), wpt.attrs.get('lon')
print("No name element in ", lat,lon)
wpt.extract()
print("===========")
with open(OUTPUTFILE, "w",encoding='utf-8') as file:
file.write(soup.prettify())
1 post - 1 participant
Ce sujet de discussion accompagne la publication sur https://community.openstreetmap.org/t/why-duplicates-after-importing-editing-and-exporting-gpx/98706