I'm not familiar with software libraries for this problem. but if you are talking in 2D space, then here is some math that comes to my mind:
you can find the distance of any 2 points in the 2D space using this calculation:
distance = sqrt( (X2 - X1)^2 + (Y2 - Y1 )^2 )
inwhich ^2 means powered by 2.
so le'ts say you have an array of Point objects (here I define a simple class for Points), this way you can find out which points are neighbored:
class Point {
    protected $_x = 0;
    protected $_y = 0;
    public function __construct($x,$y) {
         $this->_x = $x;
         $this->_y = $y;
    }
    public function getX() {
         return $this->_x;
    }
    public function getY() {
    return $this->_y;
    }    
    public function getDistanceFrom($x,$y) {
        $distance = sqrt( pow($x - $this->_x , 2) + pow($y - $this->_y , 2) );
        return $distance;
    }
    public function isCloseTo($point=null,$threshold=10) {
        $distance = $this->getDistanceFrom($point->getX(), $point->getY() );
        if ( abs($distance) <= $threshold ) return true;
        return false;
    }
    public function addNeighbor($point) {
        array_push($this->_neighbors,$point);
        return count($this->_neighbors);
    }
    public function getNeighbors() {
        return $this->_neighors;
    }
}
$threshold = 100; // the threshold that if 2 points are closer than it, they are called "close" in our application
$pointList = array();
/*
 * here you populate your point objects into the $pointList array.
*/
// you have your coordinates, right?
$myPoint = new Point($myXCoordinate, $myYCoordinate);
foreach ($pointList as $point) {
   if ($myPoint->isCloseTo($point,$threshold) {
       $myPoint->addNeighbor($point);
   }
}
$nearbyPointsList = $myPoint->getNeighbors();
edit: I'm sorry, I had forgotten the linear distance formula. both X and Y axis distance values should be powered by 2 and then the sqrt of their sum is the result. the code is now corrected.