Closed GoogleCodeExporter closed 9 years ago
Efficient weights creations with spherical coordinates...
Based on Scipy-user listserve post:
"convert all the points in question to 3D cartesian coordinates at the
beginning, and use the kd-tree as it is. The distances involved will change,
but the nearest-neighbors should still be the same points",
http://mail.scipy.org/pipermail/scipy-user/2009-June/021458.html
If this holds true (which I believe it does), we can convert lat/lng to unit
sphere XYZ, find k nearest neighbors using a 3D kd-tree, then (if needed)
calculate the surface distances.
For threshold distances, convert the surface distance in S2 to a straight line
distance in R3 and use the KDTree ball query.
I have some code with empirically tests arc_dist vs. xyz_dist using brute force
KNN. Both return the same results.
still need a function to convert surface distance to straight line distance...
(how to find a point x surface units from a reference point?)
Original comment by schmi...@gmail.com
on 30 Sep 2011 at 3:09
Function relating arc (surface) distance in S2 to euclidean distance in R3
(unit sphere)...
Given surface distance, d, in kilometers.
Given circumference of earth, r, in kilometers.
theta = (d*360)/c
e = (2-2*cos(theta))**(0.5)
Where, e is the euclidean distance in R3 in the unit sphere.
Original comment by schmi...@gmail.com
on 30 Sep 2011 at 3:41
[deleted comment]
GeoDa does give you the option to select Arc Distance for threshold distance
weights, but not for kNN.
For kNN, GeoDa does use kd-trees for kNN. It uses the "Approximate Nearest
Neighbor" library code (ANN) with the following license:
ANN Library: Approximate Nearest Neighbor Library
Release 0.1, 1998, By: Sunil Arya and David Mount
of University of Maryland
License: can be copied and distributed free of chare as long as:
(1) not part of a commercial product
(2) this notice appears in all copies of the software and related
documentation
Original comment by mmcc...@gmail.com
on 30 Sep 2011 at 12:54
I added some spherical distance tools to cg in r1002. Need unit tests and more
documentation.
Original comment by schmi...@gmail.com
on 6 Oct 2011 at 7:09
completed in r1009.
Steps to create ArcWeights...
1. Create an instance of ArcKDTree
2. pass it to your desired distance method.
Original comment by schmi...@gmail.com
on 12 Oct 2011 at 10:47
Original issue reported on code.google.com by
schmi...@gmail.com
on 30 Sep 2011 at 12:14