Skip to main content

Geocoding enrichment using Google Maps API

Project description

datasette-enrichments-gmap-geocode

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

File details

Details for the file datasette-enrichments-gmap-geocode-0.1.1.tar.gz.

File metadata

File hashes

Hashes for datasette-enrichments-gmap-geocode-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2be5ddcdd156880a1383c03bd7e92f61fa7b148b38547188f19e077da38ac201
MD5 aefb9374151f970b349fcb96e90bba25
BLAKE2b-256 95dd103ffec2b0399eded6f6411ff5accdd52ebbde3d3bb9e1943b3f9ffa851c

See more details on using hashes here.

File details

Details for the file datasette_enrichments_gmap_geocode-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for datasette_enrichments_gmap_geocode-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 38c16f97382e24f86f1881d2404f72c5f7c3c01f7e83d54980d6a8b7b81a0f46
MD5 7cf820f5ad78f65d83bb7ab8f3618dcb
BLAKE2b-256 efea149fbe92369dd37c3f7cf4ba11bea1eec8394acd281523a450d424575d79

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page