Script to use Overpass data in JOSM

Posted by Squizie3 on 18 June 2019 in English.

I’m quite new to the OGF community, but I have much longer experience on OSM. On OSM I got quite used to extracting data through Overpass and then editing the desired dataset in JOSM. Since the time I’ve been here on OGF, I’ve tried and constantly failed at doing the same with the dedicated OGF Overpass, only to find out it’s simply impossible. This is because the Overpass server stores no metadata anymore since the GDPR law went into effect, and that metadata is required to edit the dataset in JOSM. But… I found a workaround! I wrote a one click script to extract all IDs from a .osm Overpass dataset into a single list, so you can easily paste this into the ‘Download objects’ dialog in JOSM. JOSM will then download exactly what you previously got as output from Overpass Turbo, and you’re ready to edit right away!

So how do you get this to work? First you have to download your data from Overpass Turbo as you would normally do (‘out meta’ isn’t necessary, ‘out skel’, ‘out geom’, ‘out’, or even ‘out ids’ will all do the job). Then click ‘export’ > ‘raw data’, this will download a file called ‘export.osm’. Next you run the script you can download here by simply double clicking the batch script which will run the other script (which is a PowerShell script). Make sure the export.osm file is in the same folder as the script. The script will run and in a matter of seconds you will have a new file called ‘List.txt’ which contains a list of all IDs, and they’re automatically copied to your clipboard too. In JOSM, paste this list into the ‘Download objects’ dialog. Make sure object type is set to ‘mixed’, and in your JOSM preferences the checkbox ‘Use Overpass server to download objects’ is disabled in the connection settings. Then you just have to click ‘download’ and voila, your data is loaded into JOSM.

It’s really simple to use this method, and if you want you can make it even simpler. I’ve put a few parameters in the beginning of the PowerShell script you can easily change by right-clicking the file in Windows Explorer and then ‘edit’. Here you can change the input and/or output file path and name, along with a few other options such as ‘No output file’ or ‘Automatically delete input file’. I added descriptions next to each parameter so it will be clear what everything does.

I will probably create a small tutorial with some visual feedback on the wiki too, so it’ll be more clear and it’s easier to find so this method can be used by future mappers as well. I hope you all like it, let me know what you think of it. Happy mapping!

Squizie3

Discussion

Comment from Megacity2005Creator on 18 June 2019 at 01:58

If I understood how to do any of that, I would love it.

Comment from Squizie3 on 18 June 2019 at 02:12

That’s why I will create a wiki article about it with some visual feedback on how to do it ;) In practice it’s really simple, my explanation here is just a bit unrefined probably. So please hold on, it’ll get clear.

Comment from Fluffr_Nuttr on 18 June 2019 at 02:47

Sorry if it’s a stupid question, but what is the advantage of extracting data from the Overpass query as opposed to downloading a section of the map in the JOSM editor?

Comment from Squizie3 on 18 June 2019 at 03:34

That really depends on what you want to do. In most cases you’re simply mapping an area and this method will have no advantages at all. But in some cases when you’re doing work on a higher level this method can really save you a headache. Let’s say you want to streamline road numbering in an entire country, or you want to edit large geometries such as your countries’ mountain range, or you’re making route relations for a large network such as e.g. the Gobrassanya High Speed Rail network, it’s really useful to just simply download everything you want at once instead of a whole lot of smaller downloads. As a bonus it will make your map clutter free even without using filters.

Comment from Rhiney boi on 20 June 2019 at 03:32

Or coastline corrections.

Leave a comment

Log in to leave a comment