OpenStreetMap 로고 OpenStreetMap

osmdiff 0.3.2

mvexel님이 English로 2022년 10월 13일에 게시함.

I’ve spent a few evenings and spare hours this week dusting off and updating osmdiff. If you’re a python developer and you need to interact with replication diffs or augmented diffs, this may just be something of interest to you. osmdiff can retrieve replication diffs as well as augmented diffs from OSM servers, and parse them into native Python Node, Way and Relation objects you can use in your code. This lets you do things like

>>> from osmdiff import OSMChange
>>> o = OSMChange()
>>> o.frequency = "minute"  # the default
>>> o.get_state()  # retrieve current sequence ID
>>> o.sequence_number
2704451
>>> o.retrieve()  # retrieve from API
>>> o
OSMChange (677 created, 204 modified, 14 deleted)

Once you have the data, you can filter and inspect it:

>>> w = [n["new"] for n in a.modify if n["new"].attribs["id"] == "452218081"]
>>> w
[Way 452218081 (10 nodes)]
>>> w[0]
Way 452218081 (10 nodes)
>>> w[0].tags
{'highway': 'residential'}
>>> w[0].attribs
{'id': '452218081', 'version': '2', 'timestamp': '2017-11-10T13:52:01Z', 'changeset': '53667190', 'uid': '2352517', 'user': 'carths81'}
>>> w[0].attribs
{'id': '452218081', 'version': '2', 'timestamp': '2017-11-10T13:52:01Z', 'changeset': '53667190', 'uid': '2352517', 'user': 'carths81'}
>>> w[0].bounds
['12.8932677', '43.3575917', '12.8948117', '43.3585947']

You can also use osmdiffs implementation of Node, Way and Relation objects separately if you need just those, the library is quite small and has few dependencies (just requests and dateutil)

On the list of things in development and slated for the next release are: * Python __geo_interface__ support so you can easily use them in other Python modules that support them like shapely and geojson * Retrieving individual OSM features from the OSM API * Ability to create an AugmentedDiff / OSMChange object with a datetime parameter, which will then calculate the sequence number for you * More tests, always more tests, and CircleCI integration

If you are using osmdiff and find it useful, I would love to hear from you. If you find a bug or find something lacking, please [open an issue].

이메일 아이콘 Bluesky 아이콘 Facebook 아이콘 LinkedIn 아이콘 마스토돈 아이콘 텔레그램 아이콘 X 아이콘

토론

2022년 10월 14일 09:34Christian Ledermann님의 의견

Can you elaborate a bit more about your plans for __geo_interface__? I am the author of pygeoif and osmoapi and have some interest in making OSM more interoperable on the python side.

2022년 10월 14일 15:24mvexel님의 의견

Christian - thanks for sharing links to your work as well! The OAuth module is something I may use soon in fact.

For __geo_interface__, I think it would be great to have a canonical representation of OSM nodes, ways, relations in Python that support __geo_interface__ interoperability. I think I am probably 60% of the way there with the implementation in osmdiff. I would be happy to extract it to a separate module if that makes sense for visibility and clarity. The __geo_interface__ implementation for Relation is almost certainly too simplistic, it just iterates over the members to create a FeatureCollection right now.

There’s also OSMNx, which is widely used in the academic community but I don’t know how useful it is as a general purpose module for OSM data processing and representation. I think it’s specifically targeted at network analysis use cases, but I haven’t used it myself.

I’d love to collaborate on this.

2022년 10월 14일 16:28Christian Ledermann님의 의견

I have not worked with osmoapi for a while, I hope it is still up-to-date with the current API implementation. I used it only once to crowdsource the import of UK schools.

2022년 10월 14일 16:42mvexel님의 의견

There’s OAuth 2.0 now but 1.0a is still supported, and I guess will be for a while?

Is there a sample client app? I can probably help out a bit to dust it off if needed.

2022년 10월 14일 19:41mvexel님의 의견

There seem to be project governance related issues with PSA.

How about Requests-OAuthlib?

댓글을 남기려면 로그인하세요