Advertisement
Guest User

Untitled

a guest
Jan 19th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. import psycopg2
  2. from osmapi import OsmApi
  3. username=u''
  4. password=u''
  5. api = OsmApi(username=username, password=password,
  6. changesetauto=True, changesetautotags={"comment": u"Remove addr:country_code"})
  7. pg_dsn='user=, password=, host= ,database='
  8. con = psycopg2.connect(pg_dsn)
  9. cur = con.cursor()
  10. cur.execute("select osm_id,name from planet_osm_polygon where admin_level='9' and boundary='administrative'")
  11. data = cur.fetchall()
  12.  
  13. for poble in data:
  14. identificador = abs(poble[0])
  15. nom = poble[1]
  16. rel = api.RelationGet(identificador)
  17. if 'addr:country_code' in rel['tag']:
  18. del rel['tag']['addr:country_code']
  19. api.RelationUpdate(rel)
  20. api.flush()
  21. print 'commit: id={} poble={}'.format(identificador, nom)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement