Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import osmapi
- # Connect to OSM
- api = osmapi.OsmApi(username="osm-user", password="***")
- # Create a new changeset
- api.ChangesetCreate({u"comment": u"updating abandoned roads"})
- # Read File with way id and highway dates
- with open("East_Complex_Attributes.txt", "r") as f:
- for row in f:
- # Extract values for row
- values = row.split(",")
- nid = int(values[0].strip())
- time1 = values[1].strip()
- time2 = values[2].strip()
- print nid
- way = api.WayGet(nid)
- # If Way exists
- if way is not None:
- print way
- # Remove timestamp tag for later update
- way.pop(u'timestamp')
- # Add highway dates
- way[u"tag"][u"highway:{}".format(time1)] = u"track"
- if len(time2):
- way[u"tag"][u"highway:{}".format(time2)] = u"track"
- # Update Way
- api.WayUpdate(way)
- # If way doesn't exist
- else:
- print "skip"
- # Close Changeset
- api.ChangesetClose()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement