Ejemplo n.º 1
0
from osmapi import OsmApi
import sys

username = sys.argv[1]
searchfortag = sys.argv[2]
searchforvalue = sys.argv[3]
action = sys.argv[4]

print("Searching for tag=%s, value=%s, action=%s, user=%s" %(searchfortag, searchforvalue, action, username))

counter = 0

MyApi = OsmApi()

csets = MyApi.ChangesetsGet(username=username)

for i_cs in csets:
    changeset_info = MyApi.ChangesetGet(i_cs)
    changeset = MyApi.ChangesetDownload(i_cs)

    for i_ed in changeset:
        if i_ed['action'] == action:
            node_id = i_ed['data']['id']
            node = MyApi.NodeGet(node_id)

            try:
                if node['tag'][searchfortag] == searchforvalue:
                    counter = counter + 1
                    print("Counter: %i %s, node id: %s" % (counter, searchforvalue, node_id))
            except:
Ejemplo n.º 2
0
"""
Code to get and process data from OpenStreetMap
"""
from osmapi import OsmApi
import geopandas as gp

api = OsmApi()

# In the future, get info for a group of users
users = ['paulopp', 'Sneakytiki', 'TheLazerClap']

for my_username in users:
    # Get user changesets
    # Can limit area with min/max lat/lon, and by timeframe
    sets = api.ChangesetsGet(username=my_username)
    changeset_list = list(sets.keys())

    # Get and process changesets
    total = 0
    for id in changeset_list:
        my_changeset = api.ChangesetDownload(id)
        total = total + len(my_changeset)

    print(my_username + ': ' + str(total))