**Powerfull wrapper around OSM Overpass Turbo to query regions of any size and shape**
```bash
pip install osmpy
```
#### List precooked queries
```python
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
```python
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
```python
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
```python
## Use `{boundary}` as a placeholder.
query = """
[out:json];
node["amenity"](poly:"{boundary}");
out body geom;
"""
osmpy.get(query, boundary)
```
## Create a precooked query
```python
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)
```
:point_right: 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_.
Raw data
{
"_id": null,
"home_page": "https://github.com/JoaoCarabetta/osmpy",
"name": "osmpy",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6,<4.0",
"maintainer_email": "",
"keywords": "",
"author": "Joao Carabetta",
"author_email": "joao.carabetta@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/2b/fa/c86a35726ade04e5e399430703952995f2da3369df41e3f209180a67cbac/osmpy-0.2.0.tar.gz",
"platform": "",
"description": "**Powerfull wrapper around OSM Overpass Turbo to query regions of any size and shape**\n\n```bash\npip install osmpy\n```\n\n#### List precooked queries\n```python\nosmpy.list_queries()\n\n name docstring\n0 Amenities Location of amenities within a boundary \n1 AmentiesCount Number of amenities per type within a boundary \n2 RoadLength Length of road by roadtype within a boundary \n```\n\n#### Get all amenities in a boundary\n```python\nimport osmpy\nfrom shapely import wkt\n\nboundary = wkt.loads('POLYGON((-46.63 -23.54,-46.6 -23.54,-46.62 -23.55,-46.63 -23.55,-46.63 -23.54))')\nosmpy.get('Amenities', boundary)\n\n type id lat lon tags\n0 node 661212030 -23.544739 -46.626160 {'amenity': 'fuel', 'name': 'Posto NGM'}\n1 node 661212089 -23.547450 -46.626073 {'amenity': 'fuel', 'name': 'Posto Maserati', ...\n2 node 745733280 -23.541411 -46.613930 {'addr:city': 'S\u00e3o Paulo', 'addr:housenumber':...\n3 node 745733292 -23.542070 -46.614916 {'addr:city': 'S\u00e3o Paulo', 'addr:housenumber':...\n4 node 889763809 -23.542558 -46.620360 {'addr:housenumber': '110/C9', 'addr:street': ...\n.. ... ... ... ... ...\n84 node 5663737625 -23.540027 -46.605425 {'access': 'yes', 'addr:city': 'S\u00e3o Paulo', 'a...\n85 node 5990269247 -23.540650 -46.607532 {'addr:city': 'S\u00e3o Paulo', 'addr:housenumber':...\n86 node 6621564995 -23.543880 -46.626414 {'access': 'yes', 'addr:city': 'S\u00e3o Paulo', 'a...\n87 node 6625433725 -23.546727 -46.623956 {'access': 'yes', 'addr:city': 'S\u00e3o Paulo', 'a...\n88 node 6625433753 -23.547111 -46.624790 {'access': 'yes', 'addr:city': 'S\u00e3o Paulo', 'a...\n```\n\n#### Total road length by road type\n```python\nosmpy.get('RoadLength', boundary)\n\n count length\nhighway \nbus_stop 1 82.624\ncorridor 2 482.195\ncycleway 1 134.197\nfootway 116 5473.419\nliving_street 3 422.378\npath 4 735.539\npedestrian 3 90.327\nplatform 3 239.206\nprimary 28 2067.562\nprimary_link 12 1123.544\n```\n\n#### You can use your own query\n\n```python\n\n## Use `{boundary}` as a placeholder.\nquery = \"\"\"\n [out:json];\n node[\"amenity\"](poly:\"{boundary}\");\n out body geom;\n \"\"\"\n\nosmpy.get(query, boundary)\n```\n\n## Create a precooked query\n\n```python\nclass YourPrecookedQuery(osmpy.queries.QueryType):\n\n query = \"\"\"\n <OSM Overpass Turbo Query>\n \"\"\"\n\n docstring = \"\"\"\n <Query description>\n \"\"\"\n\n def postprocess(self, df):\n \"\"\"Post process API result\n \"\"\"\n return df['tags'].apply(pd.Series).groupby('amenity').sum()\n\nosmpy.get(YourPrecookedQuery, boundary)\n```\n\n:point_right: Leave an issue or PR if you want to add a new query to the package\n\n## Credits\n\nFree software: MIT license\n\nFunction `katana` from @snorfalorpagus_.\n",
"bugtrack_url": null,
"license": "AM-331-A3 Licencia de Software",
"summary": "Powerfull wrapper around OSM Overpass Turbo to query regions of any size and shape",
"version": "0.2.0",
"project_urls": {
"Homepage": "https://github.com/JoaoCarabetta/osmpy",
"Repository": "https://github.com/JoaoCarabetta/osmpy"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c620e68e1adc72aa2e594b76dde13ff037dc467583f46ffed22de809c1d47bfb",
"md5": "3c9bfeebe3b03857f1a98ced8c2c91bb",
"sha256": "e0ef0cddb0b75bcbd86971c54d3ecda46bafe2cbc7eacbf1ed8dec9fba7ba0c1"
},
"downloads": -1,
"filename": "osmpy-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3c9bfeebe3b03857f1a98ced8c2c91bb",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6,<4.0",
"size": 5171,
"upload_time": "2020-11-24T16:51:02",
"upload_time_iso_8601": "2020-11-24T16:51:02.096002Z",
"url": "https://files.pythonhosted.org/packages/c6/20/e68e1adc72aa2e594b76dde13ff037dc467583f46ffed22de809c1d47bfb/osmpy-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2bfac86a35726ade04e5e399430703952995f2da3369df41e3f209180a67cbac",
"md5": "fae892e3918aaebce9a4ff29c1fecfe3",
"sha256": "35637c12667bfa90fa0eb5f59417a5c132464d121c36e5486459bf7978d74680"
},
"downloads": -1,
"filename": "osmpy-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "fae892e3918aaebce9a4ff29c1fecfe3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6,<4.0",
"size": 5362,
"upload_time": "2020-11-24T16:51:03",
"upload_time_iso_8601": "2020-11-24T16:51:03.310445Z",
"url": "https://files.pythonhosted.org/packages/2b/fa/c86a35726ade04e5e399430703952995f2da3369df41e3f209180a67cbac/osmpy-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2020-11-24 16:51:03",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "JoaoCarabetta",
"github_project": "osmpy",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "shapely",
"specs": [
[
"==",
"1.7.0"
]
]
},
{
"name": "geojson",
"specs": [
[
"==",
"2.5.0"
]
]
},
{
"name": "requests",
"specs": [
[
"==",
"2.23.0"
]
]
},
{
"name": "retry",
"specs": []
},
{
"name": "pyproj",
"specs": []
},
{
"name": "pandas",
"specs": []
}
],
"lcname": "osmpy"
}