PHP Nearest Neighbor: Find nearest neighbor of a set of location points

 Version License PHP version Categories nearest-neighbor 1.0.4 BSD License 3.0 Algorithms, Graphics, Geography
Description

Author

This package can find nearest neighbor of a set of location points.

It takes a set of geographic points given their latitude and longitude and it determine the nearest neighbor of another given point.

It can also generate an image that visualizes that renders the points and the areas they form as triangles.

Innovation Award
 June 2014 Number 3Prize: One copy of the Zend Studio Certain geographic problems need to determine what is the closest point from other locations. This class can find what is the nearest neighbor point of a set of geographic locations from a given point. Manuel Lemos
 Performance Level
Name: Classes: Chi H. `` 28 packages by Chi H. France 39 340 22 in France 22 1 in France
Innovation award

Nominee: 22x

Winner: 3x

Recommendations

PHP k-means Algorithm Data Miner
I need to segments all object into appropriate number of cluster

Example

 ``` main(); list(\$tree,\$size)=\$tri->buildtree(\$set); \$nearest=new nearestneighbor(); //\$p=new Point(12,322); \$p=new Point(60,60); //\$p=new Point(26,229); \$find=\$nearest->main(\$tri,\$tree,\$p); \$nearest->show(\$tri,\$find,0,\$p);       //example2 \$set=array(); \$tree=array(172,31,238,106,233,397,118,206,58,28,268,382,10,380,342,26,67,371,380,14,382,200,24,200,194,190,10,88,276,331); for (\$i=0,\$end=count(\$tree);\$i<\$end;\$i+=2) {     \$set[]=array(\$tree[\$i],\$tree[\$i+1]); } \$tri=new voronoi(); list(\$tree,\$size)=\$tri->buildtree(\$set); \$nearest=new nearestneighbor(); //\$p=new Point(12,322); //\$p=new Point(160,160); \$p=new Point(326,229); //\$p=new Point(188,298); \$find=\$nearest->main(\$tri,\$tree,\$p); \$nearest->show(\$tri,\$find,\$size-4,\$p); // experimental point-in-polygon //\$find=\$nearest->polytest(\$tri,0,\$p); \$find=\$nearest->polytest(\$tri,\$size-4,\$p); ?> ```

 Screenshots (7)
 Files (9)
File Role Description
example.php Example example
main.php Class main class

 The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. Install with Composer
 nearest-neighbor-2014-06-11.zip 23KB nearest-neighbor-2014-06-11.tar.gz Install with Composer
For more information send a message to `info at phpclasses dot org`.