def __init__(self, r, az, sitecoords, proj, x, y, nnear=9):
self.nnear = nnear
self.az = az
self.r = r
self.x = x
self.y = y
# compute the centroid coordinates in lat/lon
bin_lon, bin_lat = georef.polar2centroids(r, az, sitecoords)
# reproject the centroids to cartesian map coordinates
binx, biny = georef.reproject(bin_lon, bin_lat,
projection_target=proj)
self.binx, self.biny = binx.ravel(), biny.ravel()
# compute the KDTree
tree = KDTree(list(zip(self.binx, self.biny)))
# query the tree for nearest neighbours
self.dist, self.ix = tree.query(list(zip(x, y)), k=nnear)
评论列表
文章目录