Name | rgcosm JSON |
Version |
0.1.2
JSON |
| download |
home_page | https://github.com/BlackCatDevel0per/rgcosm |
Summary | rgcosm simple reverse geocoding library from converted osm(.pbf) GIS data by converter in this lib |
upload_time | 2023-04-18 16:56:55 |
maintainer | |
docs_url | None |
author | bcdev |
requires_python | >=3.7 |
license | |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# RGCosm - Reverse Geocode for OpenStreetmap
[![Upload Python Package](https://github.com/BlackCatDevel0per/rgcosm/actions/workflows/python-publish.yml/badge.svg)](https://github.com/BlackCatDevel0per/rgcosm/actions/workflows/python-publish.yml)
A Python library for offline reverse geocoding from osm(.pbf) GIS converted to sqlite3 data - based on code from [rgcoms scripts](https://github.com/punnerud/rgcosm)
### Install by:
```bash
pip install rgcoms
```
or from source by:
```bash
git clone https://github.com/BlackCatDevel0per/rgcosm
cd rgcoms
pip install build
python -m build
```
### Dependencies
1. osmium
### CLI
See cli commands by:
```bash
python rgcosm -h
```
output:
```bash
usage: rgcosm [-h] [-ci CINPUT] [-co COUTPUT] [-ai ADD_INDEXES] [-db DATABASE]
[-ltln LAT_LON] [-lat LATITUDE] [-lon LONGITUDE] [-st SEARCH_TAGS]
[-mtc MIN_TAGS_COUNT] [-rd RETRIEVE_DEGREE] [-rt ROUND_TO]
rgcosm cli
optional arguments:
-h, --help show this help message and exit
-ci CINPUT, --cinput CINPUT
Path to input pbf file
-co COUTPUT, --coutput COUTPUT
Path to output db file
-ai ADD_INDEXES, --add_indexes ADD_INDEXES
Add indexes for faster search default: True
-db DATABASE, --database DATABASE
Path to db file
-ltln LAT_LON, --lat_lon LAT_LON
latitude with longitude separated by space
-lat LATITUDE, --latitude LATITUDE
latitude
-lon LONGITUDE, --longitude LONGITUDE
longitude
-st SEARCH_TAGS, --search_tags SEARCH_TAGS
tags to search, default: `addr:`
-mtc MIN_TAGS_COUNT, --min_tags_count MIN_TAGS_COUNT
Minimal tags count (for `-st/--search_tags`) to filter result,
default: 1
-rd RETRIEVE_DEGREE, --retrieve_degree RETRIEVE_DEGREE
Retrieve addresses within a +/- x degree range of the original
coordinates, default: 0.001
-rt ROUND_TO, --round_to ROUND_TO
Round degree to n decimals after dot, default: 8
```
### First convert downloaded osm(.pbf) files from:
https://download.geofabrik.de/
Then use cli to create the database (speedupped by using db in ram & dump in to disk):
```bash
python rgcosm -ci some-place.osm.pbf -co some-place.db
```
The output file can be x7-13 (for maldives file ~12.74 times) times larger then the source file, for example [maldives](https://download.geofabrik.de/asia/maldives-latest.osm.pbf) file size is 2.7 mb, and after conversion size increased to 34.4 mb (time: ~14 sec.) with added indexes and 20.1 mb without (time: ~13 sec.).
You can disable adding indexes by `-ai=no` or `--add_indexes=no` arg.
Adding indexes speedups searching time up to 70 times.
### Usage
```python
from rgcosm import get_address
db_path = 'maldives-latest.db'
coordinates = (6.5506617, 72.9530232)
addr = get_address(db_path, coordinates)
print(addr)
```
result:
```python
[{'id': 9508099415, 'lat': 6.5506617, 'lon': 72.9530232, 'tags': {'addr:block_number': '26', 'generator:method': 'combustion', 'generator:output:electricity': '200 kV', 'generator:source': 'diesel', 'name': 'Vaikaradhoo Fenaka Power Plant 3', 'operator': 'Fenaka Corporation Limited Vaikaradhoo', 'power': 'generator'}}]
```
or with multiple coordinates:
```python
from rgcosm import get_address
db_path = 'maldives-latest.db'
coordinates = [(6.5506617, 72.9530232), (4.172474, 73.5083067), (4.1718557, 73.5154427)]
addr = get_address(db_path, coordinates)
print(addr)
```
result:
```python
[{'id': 9508099415, 'lat': 6.5506617, 'lon': 72.9530232, 'tags': {'addr:block_number': '26', 'generator:method': 'combustion', 'generator:output:electricity': '200 kV', 'generator:source': 'diesel', 'name': 'Vaikaradhoo Fenaka Power Plant 3', 'operator': 'Fenaka Corporation Limited Vaikaradhoo', 'power': 'generator'}}, {'id': 2521220337, 'lat': 4.172474, 'lon': 73.5083067, 'tags': {'addr:city': "Male'", 'addr:housename': 'Ma.Seventy Flower', 'addr:street': 'Iskandharu Magu', 'amenity': 'cafe', 'cuisine': 'coffee_shop', 'internet_access': 'yes', 'name': "Chili's Café"}}, {'id': 7987147424, 'lat': 4.1718557, 'lon': 73.5154427, 'tags': {'addr:city': "Male'", 'addr:housenumber': 'H.Hostside', 'addr:postcode': '20053', 'addr:street': 'Irudheymaa Hingun', 'clothes': 'women;wedding;men;suits;fashion;children', 'contact:facebook': 'https://m.facebook.com/Aiccet/', 'currency:EUR': 'yes', 'currency:GBP': 'yes', 'currency:USD': 'yes', 'name': 'Aiccet', 'opening_hours': '24/7', 'operator': 'Aiccet', 'payment:american_express': 'yes', 'payment:cash': 'yes', 'payment:credit_cards': 'yes', 'payment:mastercard': 'yes', 'payment:visa': 'yes', 'payment:visa_debit': 'yes', 'phone': '+960 7997323', 'shop': 'clothes'}}]
```
Advanced (for keep connection to db):
```python
from rgcosm import RGeocoder
db_path = 'maldives-latest.db'
geo = RGeocoder(db_path)
coordinates = [(4.1758869, 73.5094013), (-0.6699146, 73.1228688), (5.159217, 73.1312907)]
addrs = geo.locate(coordinates, 'addr:', 1)
print(addrs)
```
result:
```python
[{'id': 10300135473, 'lat': 4.1758869, 'lon': 73.5094013, 'tags': {'addr:city': "Male'", 'email': 'silverlinehotelsupplier@gmail.com', 'name': 'Silverline Hotel Supplies', 'office': 'company', 'phone': '732-9577', 'website': 'http://www.silverlineenterprise.com/'}}, {'id': 9446166886, 'lat': -0.6699146, 'lon': 73.1228688, 'tags': {'addr:city': 'Addu City', 'addr:housenumber': 'Mushkuraanaage', 'addr:postcode': '19030', 'addr:street': 'Dhandivara Maga'}}, {'id': 8439302155, 'lat': 5.159217, 'lon': 73.1312907, 'tags': {'addr:city': 'Dharavandhoo', 'addr:postcode': '06060', 'amenity': 'courthouse', 'name': 'Dharavandhoo Magistrate Court', 'opening_hours': 'Sa-Th 08:00-14:00', 'operator': 'Government of Maldives'}}]
```
### In plans:
- [ ] db serializing with lz4 compression & etc.
- [ ] Add more formats for addresses
- [ ] Add caching results
- [ ] More speedup conversion & less memory usage
- [ ] Add some features from other similar libs
- [ ] More documentation
Raw data
{
"_id": null,
"home_page": "https://github.com/BlackCatDevel0per/rgcosm",
"name": "rgcosm",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "",
"author": "bcdev",
"author_email": "bcdev@mail.ru",
"download_url": "https://files.pythonhosted.org/packages/a8/cb/6e1f79a09d1e80bf73e48f746ef60307cc55aadd8af4c777494c7a902543/rgcosm-0.1.2.tar.gz",
"platform": null,
"description": "# RGCosm - Reverse Geocode for OpenStreetmap\n[![Upload Python Package](https://github.com/BlackCatDevel0per/rgcosm/actions/workflows/python-publish.yml/badge.svg)](https://github.com/BlackCatDevel0per/rgcosm/actions/workflows/python-publish.yml)\n\nA Python library for offline reverse geocoding from osm(.pbf) GIS converted to sqlite3 data - based on code from [rgcoms scripts](https://github.com/punnerud/rgcosm)\n\n### Install by:\n```bash\npip install rgcoms\n```\nor from source by:\n```bash\ngit clone https://github.com/BlackCatDevel0per/rgcosm\ncd rgcoms\npip install build\npython -m build\n```\n\n### Dependencies\n1. osmium\n\n### CLI\nSee cli commands by:\n```bash\npython rgcosm -h\n```\noutput:\n```bash\nusage: rgcosm [-h] [-ci CINPUT] [-co COUTPUT] [-ai ADD_INDEXES] [-db DATABASE]\n [-ltln LAT_LON] [-lat LATITUDE] [-lon LONGITUDE] [-st SEARCH_TAGS]\n [-mtc MIN_TAGS_COUNT] [-rd RETRIEVE_DEGREE] [-rt ROUND_TO]\n\nrgcosm cli\n\noptional arguments:\n -h, --help show this help message and exit\n -ci CINPUT, --cinput CINPUT\n Path to input pbf file\n -co COUTPUT, --coutput COUTPUT\n Path to output db file\n -ai ADD_INDEXES, --add_indexes ADD_INDEXES\n Add indexes for faster search default: True\n -db DATABASE, --database DATABASE\n Path to db file\n -ltln LAT_LON, --lat_lon LAT_LON\n latitude with longitude separated by space\n -lat LATITUDE, --latitude LATITUDE\n latitude\n -lon LONGITUDE, --longitude LONGITUDE\n longitude\n -st SEARCH_TAGS, --search_tags SEARCH_TAGS\n tags to search, default: `addr:`\n -mtc MIN_TAGS_COUNT, --min_tags_count MIN_TAGS_COUNT\n Minimal tags count (for `-st/--search_tags`) to filter result,\n default: 1\n -rd RETRIEVE_DEGREE, --retrieve_degree RETRIEVE_DEGREE\n Retrieve addresses within a +/- x degree range of the original\n coordinates, default: 0.001\n -rt ROUND_TO, --round_to ROUND_TO\n Round degree to n decimals after dot, default: 8\n```\n\n### First convert downloaded osm(.pbf) files from:\nhttps://download.geofabrik.de/\n\nThen use cli to create the database (speedupped by using db in ram & dump in to disk):\n```bash\npython rgcosm -ci some-place.osm.pbf -co some-place.db\n```\n\nThe output file can be x7-13 (for maldives file ~12.74 times) times larger then the source file, for example [maldives](https://download.geofabrik.de/asia/maldives-latest.osm.pbf) file size is 2.7 mb, and after conversion size increased to 34.4 mb (time: ~14 sec.) with added indexes and 20.1 mb without (time: ~13 sec.).\n\nYou can disable adding indexes by `-ai=no` or `--add_indexes=no` arg.\n\nAdding indexes speedups searching time up to 70 times.\n\n### Usage\n```python\nfrom rgcosm import get_address\ndb_path = 'maldives-latest.db'\ncoordinates = (6.5506617, 72.9530232)\naddr = get_address(db_path, coordinates)\nprint(addr)\n```\nresult:\n```python\n[{'id': 9508099415, 'lat': 6.5506617, 'lon': 72.9530232, 'tags': {'addr:block_number': '26', 'generator:method': 'combustion', 'generator:output:electricity': '200 kV', 'generator:source': 'diesel', 'name': 'Vaikaradhoo Fenaka Power Plant 3', 'operator': 'Fenaka Corporation Limited Vaikaradhoo', 'power': 'generator'}}]\n```\nor with multiple coordinates:\n```python\nfrom rgcosm import get_address\ndb_path = 'maldives-latest.db'\ncoordinates = [(6.5506617, 72.9530232), (4.172474, 73.5083067), (4.1718557, 73.5154427)]\naddr = get_address(db_path, coordinates)\nprint(addr)\n```\nresult:\n```python\n[{'id': 9508099415, 'lat': 6.5506617, 'lon': 72.9530232, 'tags': {'addr:block_number': '26', 'generator:method': 'combustion', 'generator:output:electricity': '200 kV', 'generator:source': 'diesel', 'name': 'Vaikaradhoo Fenaka Power Plant 3', 'operator': 'Fenaka Corporation Limited Vaikaradhoo', 'power': 'generator'}}, {'id': 2521220337, 'lat': 4.172474, 'lon': 73.5083067, 'tags': {'addr:city': \"Male'\", 'addr:housename': 'Ma.Seventy Flower', 'addr:street': 'Iskandharu Magu', 'amenity': 'cafe', 'cuisine': 'coffee_shop', 'internet_access': 'yes', 'name': \"Chili's Caf\u00e9\"}}, {'id': 7987147424, 'lat': 4.1718557, 'lon': 73.5154427, 'tags': {'addr:city': \"Male'\", 'addr:housenumber': 'H.Hostside', 'addr:postcode': '20053', 'addr:street': 'Irudheymaa Hingun', 'clothes': 'women;wedding;men;suits;fashion;children', 'contact:facebook': 'https://m.facebook.com/Aiccet/', 'currency:EUR': 'yes', 'currency:GBP': 'yes', 'currency:USD': 'yes', 'name': 'Aiccet', 'opening_hours': '24/7', 'operator': 'Aiccet', 'payment:american_express': 'yes', 'payment:cash': 'yes', 'payment:credit_cards': 'yes', 'payment:mastercard': 'yes', 'payment:visa': 'yes', 'payment:visa_debit': 'yes', 'phone': '+960 7997323', 'shop': 'clothes'}}]\n```\n\nAdvanced (for keep connection to db):\n```python\nfrom rgcosm import RGeocoder\ndb_path = 'maldives-latest.db'\ngeo = RGeocoder(db_path)\ncoordinates = [(4.1758869, 73.5094013), (-0.6699146, 73.1228688), (5.159217, 73.1312907)]\naddrs = geo.locate(coordinates, 'addr:', 1)\nprint(addrs)\n```\nresult:\n```python\n[{'id': 10300135473, 'lat': 4.1758869, 'lon': 73.5094013, 'tags': {'addr:city': \"Male'\", 'email': 'silverlinehotelsupplier@gmail.com', 'name': 'Silverline Hotel Supplies', 'office': 'company', 'phone': '732-9577', 'website': 'http://www.silverlineenterprise.com/'}}, {'id': 9446166886, 'lat': -0.6699146, 'lon': 73.1228688, 'tags': {'addr:city': 'Addu City', 'addr:housenumber': 'Mushkuraanaage', 'addr:postcode': '19030', 'addr:street': 'Dhandivara Maga'}}, {'id': 8439302155, 'lat': 5.159217, 'lon': 73.1312907, 'tags': {'addr:city': 'Dharavandhoo', 'addr:postcode': '06060', 'amenity': 'courthouse', 'name': 'Dharavandhoo Magistrate Court', 'opening_hours': 'Sa-Th 08:00-14:00', 'operator': 'Government of Maldives'}}]\n```\n\n### In plans:\n- [ ] db serializing with lz4 compression & etc.\n- [ ] Add more formats for addresses\n- [ ] Add caching results\n- [ ] More speedup conversion & less memory usage\n- [ ] Add some features from other similar libs\n- [ ] More documentation\n\n",
"bugtrack_url": null,
"license": "",
"summary": "rgcosm simple reverse geocoding library from converted osm(.pbf) GIS data by converter in this lib",
"version": "0.1.2",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6472a701e14f9f048082aa5e3d5f3fb340220739816427bdfc67d312d284e71b",
"md5": "e676ab69336c93bebddac0b1fbb529a0",
"sha256": "8e984fee828a74c1d05dd16183b1b4da95de3f1f1a12f573a811af1fac370686"
},
"downloads": -1,
"filename": "rgcosm-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e676ab69336c93bebddac0b1fbb529a0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 11811,
"upload_time": "2023-04-18T16:56:54",
"upload_time_iso_8601": "2023-04-18T16:56:54.670426Z",
"url": "https://files.pythonhosted.org/packages/64/72/a701e14f9f048082aa5e3d5f3fb340220739816427bdfc67d312d284e71b/rgcosm-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a8cb6e1f79a09d1e80bf73e48f746ef60307cc55aadd8af4c777494c7a902543",
"md5": "0c995ae3df75e0cc5bb2e294aa9c2161",
"sha256": "ea43f6f1730ef6857eef0ea8f83c321da7f208e1806a70b22bbb56b715d811eb"
},
"downloads": -1,
"filename": "rgcosm-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "0c995ae3df75e0cc5bb2e294aa9c2161",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 10945,
"upload_time": "2023-04-18T16:56:55",
"upload_time_iso_8601": "2023-04-18T16:56:55.862695Z",
"url": "https://files.pythonhosted.org/packages/a8/cb/6e1f79a09d1e80bf73e48f746ef60307cc55aadd8af4c777494c7a902543/rgcosm-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-04-18 16:56:55",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "BlackCatDevel0per",
"github_project": "rgcosm",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "rgcosm"
}