Re: find distance between latitude longitude pairs
Posted by
Jon K Peck on
Oct 07, 2012; 3:00pm
URL: http://spssx-discussion.165.s1.nabble.com/find-distance-between-latitude-longitude-pairs-tp5715518p5715520.html
Note that by default, distances are in
radians. For degrees, one would add inradians=False to the function
call.
Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
new phone: 720-342-5621
From:
Art Kendall <[hidden email]>
To:
[hidden email]
Date:
10/07/2012 07:30 AM
Subject:
[SPSSX-L] find
distance between latitude longitude pairs
Sent by:
"SPSSX(r)
Discussion" <[hidden email]>
Posting this as an example since it took me a while
to get it straight.
new file.
data list list/spss_id (f3) latitude2 longitude2 latitude3
longitude3(4f10.6).
begin data.
3 41.564120 -70.621997 41.5641200 -70.6219969
30 42.193804 -72.551061 42.1938041 -72.5510614
76 42.100420 -71.083124 42.1004200 -71.0831240
129 42.100402 -72.587481 42.1004016 -72.5874809
168 42.466624 -70.941887 42.4664870 -70.9417780
169 42.359188 -71.059357 42.3591884 -71.0593569
179 42.517628 -70.889178 42.5176281 -70.8891777
231 41.561571 -70.611658 41.5615710 -70.6116580
233 42.369541 -71.036692 42.3695327 -71.0366994
243 42.192191 -73.364135 42.1921907 -73.3641348
244 42.290772 -71.048702 42.2907719 -71.0487020
288 42.307968 -70.983033 42.3079854 -70.9830461
310 42.307968 -70.983033 42.3079854 -70.9830461
395 42.191997 -73.372314 42.1919973 -73.3723135
397 42.300410 -71.105673 42.3004095 -71.1056729
end data.
*after downloading anything.py move it to C:\Program
Files\IBM\SPSS\Statistics\21\extensions\anything.py.
begin program.
help(extendedTransforms)
end program.
* note case of python words like "extendedTransforms.ellipseDist"
must
be exact.
SPSSINC TRANS RESULT=milesoff TYPE=0
/FORMULA
extendedTransforms.ellipseDist(lat1=latitude2,lon1=longitude3,lat2=latitude3,lon2=
longitude3).
compute feetoff = rnd(5280*milesoff).
formats feetoff (f6).
descriptives vars = feetoff.
--
Art Kendall
Social Research Consultants
=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD