After few days of working with the quality assurance of the original OSM data extracted I finally finished the python script that generates the administrative boundary relations from level 5 to level 9
All the .osm files(original and results) can be downloaded here to check them out.
Here are the statistics and screenshots:
- Original ways: 7717 (between level 8 and some level 9)
- (after conversion) Splitted ways/segments: 21627
admin_level=9(in Indonesia: RT) 5006
admin_level=8 (RW) Total: 2708
admin_level=7 (Desa) Total: 263
admin_level=6 (Kecamatan) Total: 44
admin_level=5 (Kabupaten) Total: 5
The script takes all the ways from the OSM file and detects the intersections with other ways in order to split them into small segments(some segments will belong to different administrative boundaries).
It's important that if you want to use the script to convert the boundaries into OSM format, take a good look at it, understand it, and ask for help if there is something that doesn't understand. The script can be found here: create_administrative_boundaries.py. I added enough comments, you can use github to send feedback too.
The script is specific for the current data from Jakarta, it would be very hard or hardly impossible to make a universal script that can work with any data, therefore it's better to understand it and modify it for your needs. You can also send me a private message or email at capiscuas AT gmail DOT com if you want help with some boundaries conversion.
During the creation of the script, many warnings or errors appeared when the data had some gaps or duplicates, for example some level9 or level8 names were missing, or had some typos, or some ways had the wrong level5(For example I found a small part of Central Jakarta inside East Jakarta boundary.
You will also see in the original file I had to add some auxiliary ways in the external(outter) parts of the region in order to force the splits(for those nodes shared by more than 3 ways which didn't happen at the external part).
The HOT Indonesia data regarding flood management has been saved also in the relations, if that is not needed anymore, it can be easily removed later on with JOSM from the database.
I would like interested people in the area to give some feedback before importing all the generated relations and remove the current ways from OSM.
Things to do: -Simplify all the ways(some ways have many nearby nodes with similar angle). -After uploading the new boundaries I will join the external ways with with the neighbouring level4 areas.