title: How to get nearest neighbor of object point that have point_id using tree of Spatial.kdTree
body: <p>Help me. I'm stuck. I have a <code>class</code> of <code>point</code>. The attributes of that class are <code>lat</code>, <code>Long</code>, <code>point_id</code>, <code>name</code>. There some points that has same <code>Lat</code>, and <code>Long</code>. So, i need <code>point_id</code> as points identity. Actually, I want to get nearest neighbor of my point using tree of <code>kdTree</code>. I have no problem when I construct <code>kdTree</code>, but when I want to know my point nearest neighbor, the result is list <code>(Lat,Long)</code> of nearest neighbor whereas I want <code>point_id</code> as my result because there are some points have same <code>Lat</code>, and <code>Long</code>. </p>
  
  <p>This is my code: </p>
  
  <pre><code>import numpy as np
  from scipy import spatial
  import psycopg2
  import math
  import psycopg2.extensions   
  
  class Point:
  def __init__(self, id_point, name, Lat, Long):
      self.id_point=id_point
      self.name=name
      self.Lat=Lat
      self.Long=Long
  
  def Struktur_KdTree(points):
      tree= spatial.KDTree(points)
      return tree
  
  def getNearestPoint(tree,point,radius):
      return tree.query_ball_point(point,radius)
  
  try:
     conn = psycopg2.connect("dbname='Chicago_crime' user='postgres' host='localhost' password='1234'")
  except :
      print "I'm unable to connect to the database"
  
  cur = conn.cursor()
  cur.execute("""SELECT id_objek, primary_descript, lat, long from data_crime""")
  
  data = []
  Lat = []
  Long = []
  for id_jenis, jenis, lat, long in cur.fetchall():
       data.append(Point(id_point,name,Lat,Long))
       Lat.append(lat)
       Long.append(long)
  
  dataPoints = zip (Lat,Long)
  
  tree = Struktur_KdTree(dataPoints)
  result=[]
  radius=2
  for point in dataPoint:
     result.append(getNearestPoint(tree,point,radius))
  </code></pre>
  
  <p>Please give me any suggestion? </p>