×
BigML is working hard to support a wide range of browsers. Your experience will be better with:
English
Sign up / in
Sign up
Sign in
or Sign in with...
Amazon
Github
GitLab
Google
Toggle navigation
PRODUCT
Features
Releases
What's New
GETTING STARTED
PRICING
Subscriptions
Private Deployments
Training
Certifications
BigML for Education
SUPPORT
Toggle navigation
PRODUCT
Features
Releases
What's New
GETTING STARTED
PRICING
Subscriptions
Private Deployments
Training
Certifications
BigML for Education
SUPPORT
License
Oops!
We could not process your request!
Lat/long distance from a reference point v2 | BigML.com
×
Embed this Script in your web site
Copy & Paste this code into your HTML code:
petersen
Public
petersen's
Scripts
2
Models
0
Datasets
0
151
FREE
BUY
Lat/Long Distance from a reference point v2
Details:
Created
Tue, 8 Nov 2016 08:11:53 +0000
Published
Tue, 8 Nov 2016 09:05:26 +0000
Description:
Extends a dataset with the distance in meters between lat/long fields and a reference point.
Tags:
geolocation
latitude
longitude
URL:
https://horizon.bigml.com/user/petersen/gallery/script/582188c949c4a14ae2000f77
Script
FREE
Source code
; Computes the distance between lat/long coordinates and a reference point ; All lat/long coordinates must be in signed degrees (no N/W/S/E etc) ; ; inputs are the dataset to transform, the field names of the ; LATITUDE and LONGITUDE in the dataset and the LAT/LONG coordinates of a ; reference point. ; ; output is a new dataset with the distance, in meters, between the ; LAT/LONG field and the reference point in a new column named "Distance (m)" ; ; This implementation is based on code provided here: ; http://www.movable-type.co.uk/scripts/latlong.html (define (latlong-ref-dist dataset-in lat-field long-field lat-ref long-ref) (let (haversine (flatline "(let (R 6371000 " " latA (to-radians {lat-ref}) " " latB (to-radians (field {{lat-field}}))" " latD (- latB latA)" " longD (to-radians (- (field {{long-field}})" " {long-ref}))" " a (+ (square (sin (/ latD 2)))" " (* (cos latA)" " (cos latB)" " (square (sin ( / longD 2)))))" " c (* 2 (asin (min (list 1 (sqrt a))))))" " ( * R c ))")) (create-and-wait-dataset {"origin_dataset" dataset-in "new_fields" [{"field" haversine "name" "Distance (m)"}]}))) (define dataset-out (latlong-ref-dist dataset-in lat-field long-field lat-ref long-ref))
Description
Extends a dataset with the distance in meters between lat/long fields and a reference point.
Extends a dataset with the distance in meters between lat/long fields and a reference point.
Show more
Inputs
Outputs
License:
Creative Commons Zero V1.0
Script
FREE
Lat/long distance from a reference point v2 | BigML.com
Sending Request...
Sending Request...