Skip to main content

Datasette plugin that adds a custom SQL function for haversine distances

Project description

datasette-haversine

PyPI Changelog Tests License

Datasette plugin that adds a custom SQL function for haversine distances

Install this plugin in the same environment as Datasette to enable the haversine() SQL function.

datasette install datasette-haversine

The plugin is built on top of the haversine library.

haversine() to calculate distances

select haversine(lat1, lon1, lat2, lon2);

This will return the distance in kilometers between the point defined by (lat1, lon1) and the point defined by (lat2, lon2).

Demo

You can try this function here using Datasette Lite.

select haversine(
  40.7128, -74.0060, -- New York
  37.7749, -122.4194, -- San Francisco
  'mi'
) as distance_in_miles;

Custom units

By default haversine() returns results in km. You can pass an optional third argument to get results in a different unit:

  • ft for feet
  • m for meters
  • in for inches
  • mi for miles
  • nmi for nautical miles
  • km for kilometers (the default)
select haversine(lat1, lon1, lat2, lon2, 'mi');

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

datasette-haversine-0.2.1.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

datasette_haversine-0.2.1-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file datasette-haversine-0.2.1.tar.gz.

File metadata

  • Download URL: datasette-haversine-0.2.1.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for datasette-haversine-0.2.1.tar.gz
Algorithm Hash digest
SHA256 7405fcb2aa6ca5c6c256ce34c96994d432259203af9fcd1a7b96534221d0357f
MD5 ce170f14a0e08ed8de0dfa0bc13023a4
BLAKE2b-256 af403ce30a6fe1d9b9df5c6a96d72f705514f392daf38318822c6f9beffba31c

See more details on using hashes here.

File details

Details for the file datasette_haversine-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for datasette_haversine-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6fd80f488d44cad5a868170f2db1b93c3b26d556ae70f9c690152b97a6bdd52c
MD5 3959afbccdd3fdfad7ea434860113292
BLAKE2b-256 46f725a19af39c1a4e7827e316f41fae66b07352473be1b702844bdb7a4209f0

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