datasette-enrichments-opencage


Namedatasette-enrichments-opencage JSON
Version 0.1.1 PyPI version JSON
download
home_page
SummaryGeocoding enrichment using OpenCage
upload_time2024-02-16 03:32:27
maintainer
docs_urlNone
authorSimon Willison
requires_python>=3.8
licenseApache-2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # datasette-enrichments-opencage

[![PyPI](https://img.shields.io/pypi/v/datasette-enrichments-opencage.svg)](https://pypi.org/project/datasette-enrichments-opencage/)
[![Changelog](https://img.shields.io/github/v/release/datasette/datasette-enrichments-opencage?include_prereleases&label=changelog)](https://github.com/datasette/datasette-enrichments-opencage/releases)
[![Tests](https://github.com/datasette/datasette-enrichments-opencage/workflows/Test/badge.svg)](https://github.com/datasette/datasette-enrichments-opencage/actions?query=workflow%3ATest)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/datasette/datasette-enrichments-opencage/blob/main/LICENSE)

Geocoding enrichment using OpenCage

## Installation

Install this plugin in the same environment as Datasette.
```bash
datasette install datasette-enrichments-opencage
```
## Usage

This plugin adds an enrichment for geocoding using the [OpenCage Geocoder](https://opencagedata.com/).

You will need an API key from OpenCage - you can sign up for a free trial at https://opencagedata.com/users/sign_up.

Filter for data that you wish to geocode, then apply the OpenCage geocoder enrichment.

You'll need to specify a template to be passed to the geocoder, specifying which templates should be used as the input.

If you have a single column containing the address, you can use this:

    {{ address }}

If you have separate columns for the street, city, state and country, you can use this:

    {{ street }}, {{ city }}, {{ state }}, {{ country }}

If your address column is missing the country, but all of the addresses are in the USA, you could use this:

    {{ address }}, USA

See the [OpenCage guide](https://opencagedata.com/guides/how-to-format-your-geocoding-query) for tips on how to get the best results.

By default only the latitude and longitude from the geocoder will be stored, in the `latitude` and `longitude` columns on your table. These columns will be created if they do not yet exist.

You can optionally specify a column to store the full JSON output of the geocoder. This column will also be created if it does not exist.

The full JSON format is [described here](https://opencagedata.com/api#response).

## Configuration

You can use this plugin without configuration, but you'll need to enter your API key every time you run an enrichment.

To avoid that, you can set your API key as plugin configuration like this:

```bash
export OPENCAGE_API_KEY="your-api-key"
```
Then in `metadata.yml`:
```yaml
plugins:
  datasette-enrichments-opencage:
    api_key:
      $env: OPENCAGE_API_KEY
```
Then run Datasette like this:
```bash
datasette mydatabase.db -m metadata.yml --root
```
This well give you a URL to sign in as the "root" user, which grants you access to the enrichment.

## Development

To set up this plugin locally, first checkout the code. Then create a new virtual environment:
```bash
cd datasette-enrichments-opencage
python3 -m venv venv
source venv/bin/activate
```
Now install the dependencies and test dependencies:
```bash
pip install -e '.[test]'
```
To run the tests:
```bash
pytest
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "datasette-enrichments-opencage",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "",
    "author": "Simon Willison",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/fe/c5/96d994aa68dfd312503969453937287b03dd4b93a567415b61752d528b49/datasette-enrichments-opencage-0.1.1.tar.gz",
    "platform": null,
    "description": "# datasette-enrichments-opencage\n\n[![PyPI](https://img.shields.io/pypi/v/datasette-enrichments-opencage.svg)](https://pypi.org/project/datasette-enrichments-opencage/)\n[![Changelog](https://img.shields.io/github/v/release/datasette/datasette-enrichments-opencage?include_prereleases&label=changelog)](https://github.com/datasette/datasette-enrichments-opencage/releases)\n[![Tests](https://github.com/datasette/datasette-enrichments-opencage/workflows/Test/badge.svg)](https://github.com/datasette/datasette-enrichments-opencage/actions?query=workflow%3ATest)\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/datasette/datasette-enrichments-opencage/blob/main/LICENSE)\n\nGeocoding enrichment using OpenCage\n\n## Installation\n\nInstall this plugin in the same environment as Datasette.\n```bash\ndatasette install datasette-enrichments-opencage\n```\n## Usage\n\nThis plugin adds an enrichment for geocoding using the [OpenCage Geocoder](https://opencagedata.com/).\n\nYou will need an API key from OpenCage - you can sign up for a free trial at https://opencagedata.com/users/sign_up.\n\nFilter for data that you wish to geocode, then apply the OpenCage geocoder enrichment.\n\nYou'll need to specify a template to be passed to the geocoder, specifying which templates should be used as the input.\n\nIf you have a single column containing the address, you can use this:\n\n    {{ address }}\n\nIf you have separate columns for the street, city, state and country, you can use this:\n\n    {{ street }}, {{ city }}, {{ state }}, {{ country }}\n\nIf your address column is missing the country, but all of the addresses are in the USA, you could use this:\n\n    {{ address }}, USA\n\nSee the [OpenCage guide](https://opencagedata.com/guides/how-to-format-your-geocoding-query) for tips on how to get the best results.\n\nBy default only the latitude and longitude from the geocoder will be stored, in the `latitude` and `longitude` columns on your table. These columns will be created if they do not yet exist.\n\nYou can optionally specify a column to store the full JSON output of the geocoder. This column will also be created if it does not exist.\n\nThe full JSON format is [described here](https://opencagedata.com/api#response).\n\n## Configuration\n\nYou can use this plugin without configuration, but you'll need to enter your API key every time you run an enrichment.\n\nTo avoid that, you can set your API key as plugin configuration like this:\n\n```bash\nexport OPENCAGE_API_KEY=\"your-api-key\"\n```\nThen in `metadata.yml`:\n```yaml\nplugins:\n  datasette-enrichments-opencage:\n    api_key:\n      $env: OPENCAGE_API_KEY\n```\nThen run Datasette like this:\n```bash\ndatasette mydatabase.db -m metadata.yml --root\n```\nThis well give you a URL to sign in as the \"root\" user, which grants you access to the enrichment.\n\n## Development\n\nTo set up this plugin locally, first checkout the code. Then create a new virtual environment:\n```bash\ncd datasette-enrichments-opencage\npython3 -m venv venv\nsource venv/bin/activate\n```\nNow install the dependencies and test dependencies:\n```bash\npip install -e '.[test]'\n```\nTo run the tests:\n```bash\npytest\n```\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Geocoding enrichment using OpenCage",
    "version": "0.1.1",
    "project_urls": {
        "CI": "https://github.com/datasette/datasette-enrichments-opencage/actions",
        "Changelog": "https://github.com/datasette/datasette-enrichments-opencage/releases",
        "Homepage": "https://github.com/datasette/datasette-enrichments-opencage",
        "Issues": "https://github.com/datasette/datasette-enrichments-opencage/issues"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4b506d7a3abb6da63b36c188c09146d413eb681586378f4e8ebdc0c6d163abf6",
                "md5": "90d311ae9e59f8e4e353387a294c8b34",
                "sha256": "a06ec04490ebe96da216296a60aa94da8e078737134b7c40092b0f7444ece5b8"
            },
            "downloads": -1,
            "filename": "datasette_enrichments_opencage-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "90d311ae9e59f8e4e353387a294c8b34",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 8984,
            "upload_time": "2024-02-16T03:32:25",
            "upload_time_iso_8601": "2024-02-16T03:32:25.642577Z",
            "url": "https://files.pythonhosted.org/packages/4b/50/6d7a3abb6da63b36c188c09146d413eb681586378f4e8ebdc0c6d163abf6/datasette_enrichments_opencage-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fec596d994aa68dfd312503969453937287b03dd4b93a567415b61752d528b49",
                "md5": "fc71ec6ec387a00fa6ed673756b50912",
                "sha256": "04087586a42f29059a3b715fc246c8f9a1c3c21af89414e71060bd8bb2aa144f"
            },
            "downloads": -1,
            "filename": "datasette-enrichments-opencage-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "fc71ec6ec387a00fa6ed673756b50912",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 9187,
            "upload_time": "2024-02-16T03:32:27",
            "upload_time_iso_8601": "2024-02-16T03:32:27.200027Z",
            "url": "https://files.pythonhosted.org/packages/fe/c5/96d994aa68dfd312503969453937287b03dd4b93a567415b61752d528b49/datasette-enrichments-opencage-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-16 03:32:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "datasette",
    "github_project": "datasette-enrichments-opencage",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "datasette-enrichments-opencage"
}
        
Elapsed time: 0.17488s