Skip to main content

datasette-enrichments-gmap-geocode

PyPI Changelog Tests License

Geocoding enrichment using Google Maps API Everything in this repository is a refinement of the OpenCage repository adapted to use Google Maps instead

Installation

Install this plugin in the same environment as Datasette.

datasette install datasette-enrichments-gmap-geocode

Usage

This plugin adds an enrichment for geocoding using the Google Maps Geocoder.

You will need an API key from Google Maps - you can sign up for a key that includes free usage that's fairly large Google Maps API Key.

Filter for data that you wish to geocode, then apply the Google Maps API 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 Googlel Maps Geocoding docs 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 MAPS_API_KEY="your-api-key"

Then in metadata.yml:

plugins:
  datasette-enrichments-gmap-geocode:
    api_key:
      $env: MAPS_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-gmap-geocode
python3 -m venv venv
source venv/bin/activate

Now install the dependencies and test dependencies:

pip install -e '.[test]'

To run the tests:

pytest

Command for testing with freedraw

python3 -m datasette gm_test.db --metadata qso_loc.yml --load-extension=/usr/lib/x86_64-linux-gnu/mod_spatialite.so --template-dir plugins/templates --root

Release files for datasette-enrichments-gmap-geocode 0.1.3

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-gmap-geocode 0.1.3
File Size Uploaded
datasette-enrichments-gmap-geocode-0.1.3.tar.gz 9.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for datasette-enrichments-gmap-geocode 0.1.3
File Interpreter ABI Platform
datasette_enrichments_gmap_geocode-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 19.0 kB

Release files / datasette-enrichments-gmap-geocode-0.1.3.tar.gz

Download URL datasette-enrichments-gmap-geocode-0.1.3.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
edab86cb8c72b5e29765fa3ebc0c711c28f2b06791f7bd35a140f6ac85f9225b
BLAKE2b-256 checksum
How to use checksums
b416e17eea98a1616088d07c5eedd2a2be363ae9d6049df41a33b599adf43186
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / datasette_enrichments_gmap_geocode-0.1.3-py3-none-any.whl

Download URL datasette_enrichments_gmap_geocode-0.1.3-py3-none-any.whl
Size 9.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
912116d2035a4292783aa64240a3fde8cfc211e33cecc385577103bf545555a1
BLAKE2b-256 checksum
How to use checksums
38c98ccea062b1cc09218b8091ec4bf04fbf277a37c5613d9d39b748f1d9b6cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.1

2 release files

0.1

2 release files

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