Powerfull wrapper around OSM Overpass Turbo to query regions of any size and shape
pip install osmpy
List precooked queries
osmpy.list_queries()
name docstring
0 Amenities Location of amenities within a boundary
1 AmentiesCount Number of amenities per type within a boundary
2 RoadLength Length of road by roadtype within a boundary
Get all amenities in a boundary
import osmpy
from shapely import wkt
boundary = wkt.loads('POLYGON((-46.63 -23.54,-46.6 -23.54,-46.62 -23.55,-46.63 -23.55,-46.63 -23.54))')
osmpy.get('Amenities', boundary)
type id lat lon tags
0 node 661212030 -23.544739 -46.626160 {'amenity': 'fuel', 'name': 'Posto NGM'}
1 node 661212089 -23.547450 -46.626073 {'amenity': 'fuel', 'name': 'Posto Maserati', ...
2 node 745733280 -23.541411 -46.613930 {'addr:city': 'São Paulo', 'addr:housenumber':...
3 node 745733292 -23.542070 -46.614916 {'addr:city': 'São Paulo', 'addr:housenumber':...
4 node 889763809 -23.542558 -46.620360 {'addr:housenumber': '110/C9', 'addr:street': ...
.. ... ... ... ... ...
84 node 5663737625 -23.540027 -46.605425 {'access': 'yes', 'addr:city': 'São Paulo', 'a...
85 node 5990269247 -23.540650 -46.607532 {'addr:city': 'São Paulo', 'addr:housenumber':...
86 node 6621564995 -23.543880 -46.626414 {'access': 'yes', 'addr:city': 'São Paulo', 'a...
87 node 6625433725 -23.546727 -46.623956 {'access': 'yes', 'addr:city': 'São Paulo', 'a...
88 node 6625433753 -23.547111 -46.624790 {'access': 'yes', 'addr:city': 'São Paulo', 'a...
Total road length by road type
osmpy.get('RoadLength', boundary)
count length
highway
bus_stop 1 82.624
corridor 2 482.195
cycleway 1 134.197
footway 116 5473.419
living_street 3 422.378
path 4 735.539
pedestrian 3 90.327
platform 3 239.206
primary 28 2067.562
primary_link 12 1123.544
You can use your own query
## Use `{boundary}` as a placeholder.
query = """
[out:json];
node["amenity"](poly:"{boundary}");
out body geom;
"""
osmpy.get(query, boundary)
Create a precooked query
class YourPrecookedQuery(osmpy.queries.QueryType):
query = """
<OSM Overpass Turbo Query>
"""
docstring = """
<Query description>
"""
def postprocess(self, df):
"""Post process API result
"""
return df['tags'].apply(pd.Series).groupby('amenity').sum()
osmpy.get(YourPrecookedQuery, boundary)
👉 Leave an issue or PR if you want to add a new query to the package
Credits
Free software: MIT license
Function katana from @snorfalorpagus_.
Metadata
Release files for osmpy 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| osmpy-0.2.0.tar.gz | 5.4 kB | Without provenance | Details for osmpy-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| osmpy-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for osmpy-0.2.0-py3-none-any.whl |
Total release size: 10.5 kB
Release files / osmpy-0.2.0.tar.gz
| Download URL | osmpy-0.2.0.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
35637c12667bfa90fa0eb5f59417a5c132464d121c36e5486459bf7978d74680
|
|
BLAKE2b-256 checksum How to use checksums |
2bfac86a35726ade04e5e399430703952995f2da3369df41e3f209180a67cbac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.4 CPython/3.7.9 Linux/4.14.193-113.317.amzn1.x86_64
|
Release files / osmpy-0.2.0-py3-none-any.whl
| Download URL | osmpy-0.2.0-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e0ef0cddb0b75bcbd86971c54d3ecda46bafe2cbc7eacbf1ed8dec9fba7ba0c1
|
|
BLAKE2b-256 checksum How to use checksums |
c620e68e1adc72aa2e594b76dde13ff037dc467583f46ffed22de809c1d47bfb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.4 CPython/3.7.9 Linux/4.14.193-113.317.amzn1.x86_64
|
Security for osmpy 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.