2

When I say coordinates I mean latitude and longitude coordinates of earth. I want to determine if a set of coordinates are within the same area (my cutoff is 200 miles). I've been googling "cluster alorithm" but I'm uncertain which would work best for me.

Thanks

Amro
  • 123,847
  • 25
  • 243
  • 454
Nick Dat Le
  • 369
  • 4
  • 12
  • 1
    I would say ... project those coordinates onto x-y plane as if the Earth was properly flattened, while preserving distances ... maybe it won't. My knowledge of geometry is very basic. However, at 200 miles the distortion must be small, beyond that - you do not care. After you have these points, you can employ one of standard `2D` algorithms. – Hamish Grubijan Jun 02 '10 at 17:31
  • 1
    Ideally, however, there is a generic algorithm for `2D`, into which you could plug a distance-calculating function. – Hamish Grubijan Jun 02 '10 at 17:34
  • 1
    Yes, DBSCAN, k-means all work. It's implemented in C# in the IMSL stat library which I already have a license. Thank you for yoru reply. – Nick Dat Le Jun 02 '10 at 21:32

2 Answers2

1

Enjoy: http://www.movable-type.co.uk/scripts/latlong.html

Formula used is:

d = acos(sin(lat1).sin(lat2)+cos(lat1).cos(lat2).cos(long2−long1)).R

In which d is the distance, R is earth's radius, and {(lat1;long1), (lat2;long2)} are the two coordinates.

ANeves
  • 6,219
  • 3
  • 39
  • 63
  • 1
    Thanks, but I know that formula alerady. I need to figure out if a set or points are within a cluster. There are some algorithms out there already (DBSCAN, OPTICS) but I was hoping for something like a library that someone already wrote, either paid or free. – Nick Dat Le Jun 02 '10 at 17:28
  • I don't know of any such library as you're looking for... and I don't know of any way to ensure they're all within a 200 miles radius except by calculating the length of every edge that connects two points. – ANeves Jun 04 '10 at 09:43
1

The IMSL C# library has k-means, DBSCAN, and other cluster analysis function. I already have a license so I'm going to use this library.

Nick Dat Le
  • 369
  • 4
  • 12