Created
September 28, 2024 14:52
-
-
Save nz-angel/929e36994a2641301502f12c8ffb0d4e to your computer and use it in GitHub Desktop.
Makes a file to list the id of the objects to be deleted by osmium removeid
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" When we delete nodes from an .osm using JOSM, the nodes remain in the file marked as deleted. This | |
scripts creates a .txt with the ids of the deleted objects (nodes, ways and relations) to use as input for the function | |
'removeid' from osmium in order to remove them from the file. """ | |
import xml.etree.ElementTree as ET | |
filename = 'path_to_the.osm' | |
osm_tree = ET.parse(filename) | |
root = osm_tree.getroot() | |
with open(f'ids_to_delete.txt', 'w') as f: | |
for child in root: | |
try: | |
if child.attrib['action'] == 'delete': | |
f.write(f'{child.tag[0]}{child.attrib["id"]}\n') | |
except KeyError: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment