Datasette plugin that adds a custom SQL function for haversine distances
Project description
datasette-haversine
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 feetm
for metersin
for inchesmi
for milesnmi
for nautical mileskm
for kilometers (the default)
select haversine(lat1, lon1, lat2, lon2, 'mi');
Project details
Release history Release notifications | RSS feed
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-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7405fcb2aa6ca5c6c256ce34c96994d432259203af9fcd1a7b96534221d0357f |
|
MD5 | ce170f14a0e08ed8de0dfa0bc13023a4 |
|
BLAKE2b-256 | af403ce30a6fe1d9b9df5c6a96d72f705514f392daf38318822c6f9beffba31c |
File details
Details for the file datasette_haversine-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: datasette_haversine-0.2.1-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6fd80f488d44cad5a868170f2db1b93c3b26d556ae70f9c690152b97a6bdd52c |
|
MD5 | 3959afbccdd3fdfad7ea434860113292 |
|
BLAKE2b-256 | 46f725a19af39c1a4e7827e316f41fae66b07352473be1b702844bdb7a4209f0 |