Skip to main content

datasette-enrichments-opencage

PyPI Changelog Tests License

Geocoding enrichment using OpenCage

Installation

Install this plugin in the same environment as Datasette.

datasette install datasette-enrichments-opencage

Usage

This plugin adds an enrichment for geocoding using the OpenCage Geocoder.

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 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.

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:

export OPENCAGE_API_KEY="your-api-key"

Then in metadata.yml:

plugins:
  datasette-enrichments-opencage:
    api_key:
      $env: OPENCAGE_API_KEY

Then run Datasette like this:

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:

cd datasette-enrichments-opencage
python3 -m venv venv
source venv/bin/activate

Now install the dependencies and test dependencies:

pip install -e '.[test]'

To run the tests:

pytest

Metadata

Release files for datasette-enrichments-opencage 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for datasette-enrichments-opencage 0.1.1
File Size Uploaded Provenance Actions
datasette-enrichments-opencage-0.1.1.tar.gz 9.2 kB Without provenance Details for datasette-enrichments-opencage-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for datasette-enrichments-opencage 0.1.1
File Interpreter ABI Platform Actions
datasette_enrichments_opencage-0.1.1-py3-none-any.whl Python 3 none any Details for datasette_enrichments_opencage-0.1.1-py3-none-any.whl

Total release size: 18.2 kB

Release files / datasette-enrichments-opencage-0.1.1.tar.gz

Download URL datasette-enrichments-opencage-0.1.1.tar.gz
Size 9.2 kB
Tags Source
SHA-256 checksum
How to use checksums
04087586a42f29059a3b715fc246c8f9a1c3c21af89414e71060bd8bb2aa144f
BLAKE2b-256 checksum
How to use checksums
fec596d994aa68dfd312503969453937287b03dd4b93a567415b61752d528b49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.8

Release files / datasette_enrichments_opencage-0.1.1-py3-none-any.whl

Download URL datasette_enrichments_opencage-0.1.1-py3-none-any.whl
Size 9.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a06ec04490ebe96da216296a60aa94da8e078737134b7c40092b0f7444ece5b8
BLAKE2b-256 checksum
How to use checksums
4b506d7a3abb6da63b36c188c09146d413eb681586378f4e8ebdc0c6d163abf6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.8

Security for datasette-enrichments-opencage 0.1.1

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page