[OSM-dev] Querying Changeset Tags in OSM API

Pierre Béland pierzenh at yahoo.fr
Sat Jun 1 03:38:01 UTC 2013


I work with Will on the CAP103 project and succeeded yesterday to calculate daily statistics for the CAP103 geographic zone.
I adapted a python script originally written by Sebastien 
Pierrel. The OsmApi module contains changeset functions that are usefull
 to interrogate the OSM API and obtain the history of objects.

For
 a BBOX, a specific contributor and a date range, we can interrogate the
 OSM API an list the changesets. Below are examples for changeset 
ID=16327554. 

And looking more in detail about the Changeset 
function, I see that there are collection of  objects 
edited. We should be able with this historical data to calculate more 
detailed statistics (ie. objects created, modified, deleted).

It 
is quitee easy to treat this with Python script but there might be some limits when interrogating the OSM API. Then, it is possible to shorten the period analyzed.

For each changeset, you have the creation date and the  Comment variable. 
Example : Changeset collection item using osmApi.ChangesetsGet function
{16327554:
 {u'uid': 1339602, u'open': False, u'min_lat': u'19.626711', 
u'created_at': u'2013-05-28T18:08:50Z', u'max_lon': u'-71.9161975', 
u'tag': {u'comment': u'Projet cap103 edition a distance', u'created_by':
 u'JOSM/1.5 (5939 fr) Linux Ubuntu 12.04.2 LTS'}, u'user': u'John 
Carlo', u'max_lat': u'19.7288581', u'min_lon': u'-71.9958761', 
u'closed_at': u'2013-05-28T19:31:18Z', u'id': 16327554}}

The 
osmApi.ChangesetDownload is also usefull to obtain the history of 
objects. This list the various objects edited (ie. node, way, relation),
 their status (created, edited, deleted) and Tags.

Objects Collection
 using  function  osmApi.ChangesetDownload(changeset id)
{u'action': 
u'create', u'data': {u'changeset': 16327554, u'uid': 1339602, 
u'timestamp': u'2013-05-28T18:08:53Z', u'lon': -71.9755596, u'visible': 
True, u'version': 1, u'user': u'John Carlo', u'lat': 19.6543342, u'tag':
 {u'addr:housenumber': u'0869H-10-100', u'addr:street': u'Village 
Nativity Terrier-Rouge'}, u'id': 2323372166L}, u'type': u'node'}

{u'action':
 u'modify', u'data': {u'changeset': 16327554, u'uid': 1339602, 
u'timestamp': u'2013-05-28T18:08:53Z', u'nd': [330537291, 1028932465, 
330525425, 330600909, 330585780, 1028932361, 2262221592L, 330547550, 
2316028253L, 330581577, 330533684, 330575573, 330525334, 330538780, 
330551803, 330540720, 2312207865L, 330541763, 330557722, 330534653, 
330560877, 330555513, 330539911, 330579005, 330575077, 330584161, 
330538354, 330548147, 2323372173L, 330559532, 330527407, 330531707, 
330600600, 330531364, 330549754, 330541775, 330587579],
 u'tag': {u'name': u'Route Nationale # 6', u'haiti:code': u'RN', 
u'haiti:import_file': u'3.osm', u'haiti:source_file': 
u'intersect8_polyid__3.shp', u'haiti:objectid': u'1431', 
u'haiti:source': u'CNIGS and CartONG', u'haiti:type': u'Nationale', 
u'ref': u'RN 6', u'haiti:nom2': u'RN6', u'haiti:nom': u'Nationale no 6',
 u'highway': u'primary'}, u'visible': True, u'version': 3, u'user': 
u'John Carlo', u'id': 222650616}, u'type': u'way'}

{u'action': 
u'modify', u'data': {u'changeset': 16327554, u'uid': 1339602, 
u'timestamp': u'2013-05-28T18:28:07Z', u'nd': [2322223911L, 2323407166L,
 2322223910L, 2322223673L, 2322223674L, 2322223911L], u'tag': 
{u'building': u'yes'}, u'visible': True, u'version': 2, u'user': u'John 
Carlo', u'id': 223313287}, u'type': u'way'}

{u'action': 
u'delete', u'data': {u'changeset': 16327554, u'uid': 1339602, 
u'timestamp': u'2013-05-28T18:28:08Z', u'nd': [], u'tag': {}, 
u'visible': False, u'version': 2, u'user': u'John Carlo',
 u'id': 223438254}, u'type': u'way'}


 
Pierre 



>________________________________
> De : Paul Norman <penorman at mac.com>
>À : 'william skora' <skorasaurus at gmail.com>; dev at openstreetmap.org 
>Envoyé le : Vendredi 24 mai 2013 5h23
>Objet : Re: [OSM-dev] Querying Changeset Tags in OSM API
> 
>
>
>You could do this with pgsnapshot (or if just doing analysis, osm2pgsql) in the same database as changesetmd, and then do JOINs between the tables to get objects that were last modified in a changeset that had a particular tag.
> 
>This may be hampered by two things
>-          A lack of minutely diff support by changesetmd
>-          A lack of schema support in most OSM software. See http://www.postgresql.org/docs/9.1/static/ddl-schemas.html in the postgresql docs for information about schemas. osmosis
> 
>This probably isn’t exactly what you want, but I think it’s the best there is at this point. 
> 
>From:william skora [mailto:skorasaurus at gmail.com] 
>Sent: Sunday, May 05, 2013 8:50 AM
>To: dev at openstreetmap.org
>Subject: [OSM-dev] Querying Changeset Tags in OSM API
> 
> 
>Hi, 
>
>I'm curious if there's any current capabilities to filter entire objects based on the tags used on the changeset. I'm on the CAP103 team in Northern Haiti with HOT and we'd like to filter objects modified by mappers that we are training by querying changesets, instead of adding a tag to each object within a specific bbox and a changeset tag with something like source:Project=CAP103.
> 
>Ideally, I'd prefer to do this through a server-side interface (XAPI) but would be open to client-side filtering options like osmosis. 
>as I understand, Overpass isn't currently capable to do this; it is only able to query within 
>Any advice and help is appreciated. 
>
>Regards,
>Will 
>_______________________________________________
>dev mailing list
>dev at openstreetmap.org
>http://lists.openstreetmap.org/listinfo/dev
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/dev/attachments/20130601/d22a78c9/attachment-0001.html>


More information about the dev mailing list