osmdiff


Nameosmdiff JSON
Version 0.4.3 PyPI version JSON
download
home_pageNone
SummaryA read-only interface to OpenStreetMap change APIs and files
upload_time2024-05-26 00:01:06
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT
keywords openstreetmap osm diff changeset api
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # osmdiff

[![build and test](https://github.com/mvexel/osmdiff/actions/workflows/build_and_test.yml/badge.svg)](https://github.com/mvexel/osmdiff/actions/workflows/build_and_test.yml)

A read-only interface to OpenStreetMap change APIs and files. See also [pyosm](https://github.com/iandees/pyosm) which can do similar things. 

Python 3.7+

## Installing

`pip install osmdiff`

## Usage

### Reading

Retrieve the latest replication diff from the OSM API:

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

Read a replication diff from a file:

```python
>>> from osmdiff import OSMChange
>>> o = OSMChange(file="test_osmchange.xml")
>>> o
OSMChange (831 created, 368 modified, 3552 deleted)
```

Retrieve the latest Augmented Diff from Overpass:

```python
>>> from osmdiff import AugmentedDiff
>>> a = AugmentedDiff()
>>> a.get_state()
>>> a.sequence_number
2715051
>>> a.retrieve()
>>> a
AugmentedDiff (747 created, 374 modified, 55 deleted)
```

Read an augmented diff file:

```python
>>> from osmdiff import AugmentedDiff
>>> a = AugmentedDiff(file="test_adiff.xml")
>>> a
AugmentedDiff (2329 created, 677 modified, 39 deleted)
```

### Inspect contents

Get all the things that `chris66` has created:

```
>>> [n for n in a.create if n.attribs["user"] == "chris66"]
[Node 5221564287, Node 5221564288, Node 5221564289, Node 5221564290, Node 5221564291, Node 5221564292, Node 5221564293, Node 5221564294, Node 5221564295, Node 5221564296, Node 5221564297, Node 5221564298, Node 5221564299, Node 5221564301, Node 5221564302, Node 5221564303, Node 5221564304, Way 539648222 (5 nodes), Way 539648223 (5 nodes), Way 539648323 (5 nodes)]
```

Get all `residential` ways that were modified:

```python
>>> [n["new"] for n in a.modify if type(n["new"]) == Way and n["new"].tags.get("highway") == "residential"]
[Way 34561958 (3 nodes), Way 53744484 (6 nodes), Way 53744485 (6 nodes), Way 122650942 (3 nodes), Way 283221266 (4 nodes), Way 344272652 (5 nodes), Way 358243999 (13 nodes), Way 410489319 (5 nodes), Way 452218081 (10 nodes)]
```

Get all ways that were changed to `residential` from something else:

```python
>>> [n["new"] for n in a.modify if type(n["new"]) == Way and n["new"].tags.get("highway") == "residential" and n["old"].tags["highway"] != "residential"]
[Way 410489319 (5 nodes), Way 452218081 (10 nodes)]
```

Inspect details:

```python
>>> 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']
```

## Contributing

I welcome your contributions in code, documentation and suggestions for enhancements.

[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

If you find `osmdiff` useful, or you use it in commercial software, please consider sponsoring this project.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "osmdiff",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "Martijn van Exel <m@rtijn.org>",
    "keywords": "openstreetmap, osm, diff, changeset, api",
    "author": null,
    "author_email": "Martijn van Exel <m@rtijn.org>",
    "download_url": "https://files.pythonhosted.org/packages/03/0c/bf1113546746e6d60ae5f9af80bbda55697722eef8a0f6d7e236c9398554/osmdiff-0.4.3.tar.gz",
    "platform": null,
    "description": "# osmdiff\n\n[![build and test](https://github.com/mvexel/osmdiff/actions/workflows/build_and_test.yml/badge.svg)](https://github.com/mvexel/osmdiff/actions/workflows/build_and_test.yml)\n\nA read-only interface to OpenStreetMap change APIs and files. See also [pyosm](https://github.com/iandees/pyosm) which can do similar things. \n\nPython 3.7+\n\n## Installing\n\n`pip install osmdiff`\n\n## Usage\n\n### Reading\n\nRetrieve the latest replication diff from the OSM API:\n\n```python\n>>> from osmdiff import OSMChange\n>>> o = OSMChange(frequency=\"minute\")  # minute is the default frequency\n>>> o.get_state()  # retrieve current sequence ID\n>>> o.sequence_number\n2704451\n>>> o.retrieve()  # retrieve from API\n>>> o\nOSMChange (677 created, 204 modified, 14 deleted)\n```\n\nRead a replication diff from a file:\n\n```python\n>>> from osmdiff import OSMChange\n>>> o = OSMChange(file=\"test_osmchange.xml\")\n>>> o\nOSMChange (831 created, 368 modified, 3552 deleted)\n```\n\nRetrieve the latest Augmented Diff from Overpass:\n\n```python\n>>> from osmdiff import AugmentedDiff\n>>> a = AugmentedDiff()\n>>> a.get_state()\n>>> a.sequence_number\n2715051\n>>> a.retrieve()\n>>> a\nAugmentedDiff (747 created, 374 modified, 55 deleted)\n```\n\nRead an augmented diff file:\n\n```python\n>>> from osmdiff import AugmentedDiff\n>>> a = AugmentedDiff(file=\"test_adiff.xml\")\n>>> a\nAugmentedDiff (2329 created, 677 modified, 39 deleted)\n```\n\n### Inspect contents\n\nGet all the things that `chris66` has created:\n\n```\n>>> [n for n in a.create if n.attribs[\"user\"] == \"chris66\"]\n[Node 5221564287, Node 5221564288, Node 5221564289, Node 5221564290, Node 5221564291, Node 5221564292, Node 5221564293, Node 5221564294, Node 5221564295, Node 5221564296, Node 5221564297, Node 5221564298, Node 5221564299, Node 5221564301, Node 5221564302, Node 5221564303, Node 5221564304, Way 539648222 (5 nodes), Way 539648223 (5 nodes), Way 539648323 (5 nodes)]\n```\n\nGet all `residential` ways that were modified:\n\n```python\n>>> [n[\"new\"] for n in a.modify if type(n[\"new\"]) == Way and n[\"new\"].tags.get(\"highway\") == \"residential\"]\n[Way 34561958 (3 nodes), Way 53744484 (6 nodes), Way 53744485 (6 nodes), Way 122650942 (3 nodes), Way 283221266 (4 nodes), Way 344272652 (5 nodes), Way 358243999 (13 nodes), Way 410489319 (5 nodes), Way 452218081 (10 nodes)]\n```\n\nGet all ways that were changed to `residential` from something else:\n\n```python\n>>> [n[\"new\"] for n in a.modify if type(n[\"new\"]) == Way and n[\"new\"].tags.get(\"highway\") == \"residential\" and n[\"old\"].tags[\"highway\"] != \"residential\"]\n[Way 410489319 (5 nodes), Way 452218081 (10 nodes)]\n```\n\nInspect details:\n\n```python\n>>> w = [n[\"new\"] for n in a.modify if n[\"new\"].attribs[\"id\"] == \"452218081\"]\n>>> w\n[Way 452218081 (10 nodes)]\n>>> w[0]\nWay 452218081 (10 nodes)\n>>> w[0].tags\n{'highway': 'residential'}\n>>> w[0].attribs\n{'id': '452218081', 'version': '2', 'timestamp': '2017-11-10T13:52:01Z', 'changeset': '53667190', 'uid': '2352517', 'user': 'carths81'}\n>>> w[0].attribs\n{'id': '452218081', 'version': '2', 'timestamp': '2017-11-10T13:52:01Z', 'changeset': '53667190', 'uid': '2352517', 'user': 'carths81'}\n>>> w[0].bounds\n['12.8932677', '43.3575917', '12.8948117', '43.3585947']\n```\n\n## Contributing\n\nI welcome your contributions in code, documentation and suggestions for enhancements.\n\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\nIf you find `osmdiff` useful, or you use it in commercial software, please consider sponsoring this project.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A read-only interface to OpenStreetMap change APIs and files",
    "version": "0.4.3",
    "project_urls": {
        "Bug tracker": "https://github.com/mvexel/osmdiff/issues",
        "Homepage": "https://github.com/mvexel/osmdiff"
    },
    "split_keywords": [
        "openstreetmap",
        " osm",
        " diff",
        " changeset",
        " api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "02f5c51cf05ee8593c7e25e68234e7cbeabfebf9d7707307fc638ac641f07b37",
                "md5": "f0eeeb2c457821eeb83828346c842065",
                "sha256": "fd0d84c9aa502c8564272ba4874d07f3d2f1db2390701e71733dacf60e28ac92"
            },
            "downloads": -1,
            "filename": "osmdiff-0.4.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f0eeeb2c457821eeb83828346c842065",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 8131,
            "upload_time": "2024-05-26T00:01:04",
            "upload_time_iso_8601": "2024-05-26T00:01:04.219773Z",
            "url": "https://files.pythonhosted.org/packages/02/f5/c51cf05ee8593c7e25e68234e7cbeabfebf9d7707307fc638ac641f07b37/osmdiff-0.4.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "030cbf1113546746e6d60ae5f9af80bbda55697722eef8a0f6d7e236c9398554",
                "md5": "56d668433a5271e40cb73892d0ba4575",
                "sha256": "7969e28d311c0bbb240fcbdde4db24073df23696e41a030a6dd1405c96a8f480"
            },
            "downloads": -1,
            "filename": "osmdiff-0.4.3.tar.gz",
            "has_sig": false,
            "md5_digest": "56d668433a5271e40cb73892d0ba4575",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 706906,
            "upload_time": "2024-05-26T00:01:06",
            "upload_time_iso_8601": "2024-05-26T00:01:06.463233Z",
            "url": "https://files.pythonhosted.org/packages/03/0c/bf1113546746e6d60ae5f9af80bbda55697722eef8a0f6d7e236c9398554/osmdiff-0.4.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-26 00:01:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mvexel",
    "github_project": "osmdiff",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "osmdiff"
}
        
Elapsed time: 0.25688s