File: get_areas.py

package info (click to toggle)
python-overpy 0.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 556 kB
  • sloc: python: 2,235; xml: 1,055; makefile: 150
file content (21 lines) | stat: -rwxr-xr-x 438 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env python
import overpy

api = overpy.Overpass()

# fetch all areas
# More info on http://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_API_by_Example
result = api.query("""
area[name="Troisdorf"];
out;
""")

for area in result.areas:
    print(
        "Name: %s (%i)" % (
            area.tags.get("name", "n/a"),
            area.id
        )
    )
    for n, v in area.tags.items():
        print(f"  Tag: {n} = {v}")