Skip to content

Instantly share code, notes, and snippets.

@mvexel
Created April 6, 2018 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mvexel/b3a3bbcb2d593ec8b5f6d155a26f3c34 to your computer and use it in GitHub Desktop.
Save mvexel/b3a3bbcb2d593ec8b5f6d155a26f3c34 to your computer and use it in GitHub Desktop.
Get unique OSM contributors for a named area
#!/usr/bin/env python3
import overpass
area_name = "Kanab"
query = """area[name="{}"]->.slc;(node(area.slc);<;);""".format(area_name)
users = {"ids": [], "usernames": []}
api = overpass.API(debug=False)
result = api.Get(
query,
responseformat="csv(::uid,::user)",
verbosity="meta")
del result[0] # header
for row in result:
uid = int(row[0])
username = row[1]
if uid in users["ids"]:
continue
users["ids"].append(uid)
users["usernames"].append(username)
print(users)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment