From OpenStreetMap Wiki
Jump to navigation Jump to search

Python code for sorting Level0 output

My process for populating these involves exporting an Overpass query of all the un-identified waterways starting with a given letter to Level0, then sorting the output by name, and manually typing in the matching (unique) codes, then pasting the result back into Level0 and saving it. This is the Python one-liner I use to do the sorting:

open('/home/jesse/foo4_sorted', 'w').write('\n\n'.join(sorted(open("/home/jesse/foo4").read().split('\n\n'), key=lambda x:re.findall("name = .*\n", x))))

Mainly putting this here for my own reference, but it might be helpful to others, too. JesseFW (talk) 18:01, 26 November 2021 (UTC)