worldgeo


Nameworldgeo JSON
Version 1.3.2 PyPI version JSON
download
home_pageNone
Summaryworld geohash index
upload_time2024-07-22 11:34:40
maintainerNone
docs_urlNone
authorNone
requires_python>=3.11
licenseMIT
keywords geohash world index geoindex
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## worldgeo

### World geohash index

A simple, easy to use python package to get a country 
by a given geohash or raw coordinates.

### Getting started

#### Installation

```commandline
pip install worldgeo
```

#### Usage

Import the `Index` class and load an index file (we'll discuss
how to get one later on)

```python
from worldgeo import Index
i = Index.load("world5.idx")
```

Now you can resolve a geohash

```
In [3]: i.find_by_hash("9smk")
Out[3]: 'MEX'
```

or coordinates

```
In [4]: i.find_by_coord(49.2827, -123.1207) # Vancouver
Out[4]: 'CAN'
```

#### Using a pre-built index

There are pre-built indexes based on https://github.com/johan/world.geo.json/blob/master/countries.geo.json
. Given that, you don't really need to build indexes yourself, as there are ready to use files built by GitHub CI.

Pre-built indexes have various precision, check out the contents of `prebuilt` folder of this repo. 
Precision 6 means accuracy up to 1.2x1.2 km, which must be enough given the source might be even less accurate. 
Since more accurate index take much more disk and memory space, you might want to use precision 4 or 5 
(39km or 5km correspondingly) as these take only a few Mb. Higher precision (7 and above) gives an index that is
too large to fit in a default github repo, thus `ShardedIndex` was introduced. `ShardedIndex` splits the data into
multiple files and can load them in parallel using `multiprocessing`.

Pre-built indexes can be loaded with a short-cut method `load_prebuilt` that takes an index name and a precision value.
Available index names are `world` and `vatsim`. The `world` one resolves to a country alpha3 code and `vatsim` resolves
to a region ICAO.

```python
from worldgeo import Index

i = Index.load_prebuilt("vatsim", 5)
print(i.find_by_hash("ez656"))
```

The code above would resolve into `LPPC-E` which represents Lisboa FIR.

#### Building a new index

In case you still want to build a more (or less) precise index, you can do so by running

```
build-geoidx -o <output filename> -p <precision> [-t <num threads>] [-m] [-s]
```

and load the resulting file later on with `Index.load(filename)`

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "worldgeo",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": "geohash, world, index, geoindex",
    "author": null,
    "author_email": "Pavel Vorobyev <aquavitale@yandex.ru>",
    "download_url": "https://files.pythonhosted.org/packages/32/a1/f54eaeb302def677eb6f36d6461f6ecf499ac36a0f86a653b181badc9b60/worldgeo-1.3.2.tar.gz",
    "platform": null,
    "description": "## worldgeo\n\n### World geohash index\n\nA simple, easy to use python package to get a country \nby a given geohash or raw coordinates.\n\n### Getting started\n\n#### Installation\n\n```commandline\npip install worldgeo\n```\n\n#### Usage\n\nImport the `Index` class and load an index file (we'll discuss\nhow to get one later on)\n\n```python\nfrom worldgeo import Index\ni = Index.load(\"world5.idx\")\n```\n\nNow you can resolve a geohash\n\n```\nIn [3]: i.find_by_hash(\"9smk\")\nOut[3]: 'MEX'\n```\n\nor coordinates\n\n```\nIn [4]: i.find_by_coord(49.2827, -123.1207) # Vancouver\nOut[4]: 'CAN'\n```\n\n#### Using a pre-built index\n\nThere are pre-built indexes based on https://github.com/johan/world.geo.json/blob/master/countries.geo.json\n. Given that, you don't really need to build indexes yourself, as there are ready to use files built by GitHub CI.\n\nPre-built indexes have various precision, check out the contents of `prebuilt` folder of this repo. \nPrecision 6 means accuracy up to 1.2x1.2 km, which must be enough given the source might be even less accurate. \nSince more accurate index take much more disk and memory space, you might want to use precision 4 or 5 \n(39km or 5km correspondingly) as these take only a few Mb. Higher precision (7 and above) gives an index that is\ntoo large to fit in a default github repo, thus `ShardedIndex` was introduced. `ShardedIndex` splits the data into\nmultiple files and can load them in parallel using `multiprocessing`.\n\nPre-built indexes can be loaded with a short-cut method `load_prebuilt` that takes an index name and a precision value.\nAvailable index names are `world` and `vatsim`. The `world` one resolves to a country alpha3 code and `vatsim` resolves\nto a region ICAO.\n\n```python\nfrom worldgeo import Index\n\ni = Index.load_prebuilt(\"vatsim\", 5)\nprint(i.find_by_hash(\"ez656\"))\n```\n\nThe code above would resolve into `LPPC-E` which represents Lisboa FIR.\n\n#### Building a new index\n\nIn case you still want to build a more (or less) precise index, you can do so by running\n\n```\nbuild-geoidx -o <output filename> -p <precision> [-t <num threads>] [-m] [-s]\n```\n\nand load the resulting file later on with `Index.load(filename)`\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "world geohash index",
    "version": "1.3.2",
    "project_urls": {
        "Source": "https://github.com/viert/worldgeo"
    },
    "split_keywords": [
        "geohash",
        " world",
        " index",
        " geoindex"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d626675ea0bfe67e864486f70cac9660b7cef62dc8ae00976a5e797a977ad669",
                "md5": "f0b0bc4946074cd2557b7d17c9811f52",
                "sha256": "7ccf96273e443050a70084c8965bea893ae0c12358d7c07b341f314dc6c4c814"
            },
            "downloads": -1,
            "filename": "worldgeo-1.3.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f0b0bc4946074cd2557b7d17c9811f52",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 8661,
            "upload_time": "2024-07-22T11:34:39",
            "upload_time_iso_8601": "2024-07-22T11:34:39.559334Z",
            "url": "https://files.pythonhosted.org/packages/d6/26/675ea0bfe67e864486f70cac9660b7cef62dc8ae00976a5e797a977ad669/worldgeo-1.3.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "32a1f54eaeb302def677eb6f36d6461f6ecf499ac36a0f86a653b181badc9b60",
                "md5": "ed635c23c2552b8e9dcd30829fb9b8ba",
                "sha256": "13fb99bc714ac7a10442e61d63a421170cb2156fbe86005aa5fc6e05b07b1fa5"
            },
            "downloads": -1,
            "filename": "worldgeo-1.3.2.tar.gz",
            "has_sig": false,
            "md5_digest": "ed635c23c2552b8e9dcd30829fb9b8ba",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 7994,
            "upload_time": "2024-07-22T11:34:40",
            "upload_time_iso_8601": "2024-07-22T11:34:40.900824Z",
            "url": "https://files.pythonhosted.org/packages/32/a1/f54eaeb302def677eb6f36d6461f6ecf499ac36a0f86a653b181badc9b60/worldgeo-1.3.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-22 11:34:40",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "viert",
    "github_project": "worldgeo",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "worldgeo"
}
        
Elapsed time: 0.27421s