Small Python CLI to modify Therion .th2 files generated from TopoDroid to work better with Therion cartography style, and .th centerline files.
Run the script directly:
python3 th2_edit.py <file.th|file.th2|directory> [command] [options]From this folder:
python3 -m unittest discover -s testsIf no command is provided for a .th2 file, the script applies all default conversions:
line pit->line floor-stepline chimney->line ceiling-step -reverse online rock-border-> add or force-close on
For .th files, the script performs only backsight marking: it marks the station-to-station shot immediately after each extend left command as duplicate. This matches TopoDroid's backsight-before-foresight layout, retaining the backsight as survey data while excluding it from Therion's total-length calculation. The .th2 conversions and commands do not modify .th files.
th2_edit.py: main CLI script.tests/: unit tests for conversion and CLI behavior.data/: sample and working.th2files (for exampledata/AS-1p.th2).
Run commands from the repository root so paths like ./data/AS-1p.th2 work as shown.
Default conversion (no command):
python3 th2_edit.py ./data/AS-1p.th2 --in-placeMark backsights in a centerline file (enabled by default):
python3 th2_edit.py ./data/Canyon.th --in-placeLeave .th backsights unmodified:
python3 th2_edit.py ./data/Canyon.th --no-mark-backsights --in-placeProcess every .th and .th2 file directly in a directory. Directory input always writes changes in place without creating backups:
python3 th2_edit.py ./data --no-backup--in-placeand--outputare mutually exclusive.- Single-file in-place changes create
<name>.<extension>.bakby default; unchanged files are not rewritten or backed up. - Use
--no-backupto disable backup creation. --mark-backsightsis enabled by default for.thinputs; use--no-mark-backsightsto disable it.- Directory input processes only immediate
.thand.th2files, not subdirectories. It always writes changes in place without backups and cannot be used with--output.