nearest-neighbor

Finding nearest neighbor between 2 sets of dated points

↘锁芯ラ 提交于 2019-12-06 15:46:48
I have 2 sets of points, set1 and set2 . Both sets of points have a data associated with the point. Points in set1 are "ephemeral", and only exist on the given date. Points in set2 are "permanent", are constructed at a given date, and then exist forever after that date. set.seed(1) dates <- seq(as.Date('2011-01-01'),as.Date('2011-12-31'),by='days') set1 <- data.frame(lat=40+runif(10000), lon=-70+runif(10000),date=sample(dates,10000,replace=TRUE)) set2 <- data.frame(lat=40+runif(100), lon=-70+runif(100),date=sample(dates,100,replace=TRUE)) Here's my problem: For each point in set1 (ephemeral)

Quadtree Nearest Neighbour Algorithm

为君一笑 提交于 2019-12-06 08:22:46
问题 I have implemented a quadtree structure for n points as well as a method for returning an array of points within a given rectangle. I can't seem to find an algorithm to efficiently find the point that is closest to another given point. Am I missing something obvious? I assume a recursive solution is the correct approach? Am working in Objective C but pseudo code would be fine. Additionally I am actually storing lat, long data and the distance between points is along a great circle. EDIT: This

Finding the single nearest neighbor using a Prefix tree in O(1)?

旧时模样 提交于 2019-12-06 08:15:16
I'm reading a paper where they mention that they were able to find the single nearest neighbor in O(1) using a prefix tree. I will describe the general problem and then the classical solution and finally the proposed solution in the paper: Problem : given a list of bit vectors L (all vectors have the same length) and query bit vector q, we would like to find the nearest neighbor of q. The distance metric is the hamming distance (how many bits are different). The naive approach would be to go through the list and calculate the hamming distance between each vector in the list and q, which will

rethinkdb with filter and getNearest commands

故事扮演 提交于 2019-12-06 06:54:33
问题 How can execute getNearest query about the result of other command, for example a filter command? var point = r.point(-122.422876,37.777128); r.db('test').table('users'). filter({tags : 'tag'}). getNearest(point, {index: 'geodata', maxResults: 30, unit :'km'}) I have a 'users' table: [ {id: 1, tags : ['music', 'cups'], geodata: r.point()} {id: 2, tags: ['music', 'play'], geodata: r.point()} ] First I want to filter by 'tags' field and then return the nearest. The query that I have specified

Postgres: How to find nearest tsrange from timestamp outside of ranges?

依然范特西╮ 提交于 2019-12-06 06:12:22
I am modeling (in Postgres 9.6.1 / postGIS 2.3.1) a booking system for local services provided by suppliers: create table supplier ( id serial primary key, name text not null check (char_length(title) < 280), type service_type, duration interval, ... geo_position geography(POINT,4326) ... ); Each supplier keeps a calendar with time slots when he/she is available to be booked: create table timeslot ( id serial primary key, supplier_id integer not null references supplier(id), slot tstzrange not null, constraint supplier_overlapping_timeslot_not_allowed exclude using gist (supplier_id with =,

PCL kd-tree implementation extremely slow

白昼怎懂夜的黑 提交于 2019-12-06 06:03:22
问题 I am using Point Cloud Library (PCL) based C++ implementation of kd-tree nearest neighbour(NN) searching. The data set contains about 2.2 million points. I am searching NN points for every other point. The search radius is set at 2.0. To fully compute that, it takes about 12 hours! I am using windows 64 bit machine with 4GB RAM. Is it very common for kd-tree searching? I wonder if there is any other c++ library for 3D point cloud data, which is faster. I heard about ANN C++ library & CGAL,

How to speed up nearest search in Pandas (perhaps by vectorizing code)

只愿长相守 提交于 2019-12-05 21:04:35
I have two dataframes. Each one contains locations (X,Y) and a value for that point. For each point in the first dataframe I want to find the closest point in the second dataframe and then find the difference. I have code that is working, but it uses a for loop, which is slow. Any suggestions for how to speed this up? I know that it is generally a good idea to get rid of for loops in pandas, for performance, but I don't see how to do that in this case. Here is some sample code: import pandas as pd import numpy as np df1=pd.DataFrame(np.random.rand(10,3), columns=['val', 'X', 'Y']) df2=pd

Best GPU algorithm for calculating lists of neighbours

我们两清 提交于 2019-12-05 17:00:29
Given a collection of thousands of points in 3D, I need to get the list of neighbours for each particle that fall inside some cutoff value (in terms of euclidean distance), and if possible, sorted from nearest fo farthest. Which is the fastest GPU algorithm for this purpose in the CUDA or OpenCL languages? One of the fastest GPU MD codes I'm aware of, HALMD , uses a (highly tuned) version of the same sort of approach that is used in the CUDA SDK examples , "Particles". Both the HALMD paper and the Particles whitepaper are very clearly written. The underling algorithm is to assign particles

Nearest neighbor search in 2D using a grid partitioning

99封情书 提交于 2019-12-05 13:20:49
I have a fairly large set of 2D points (~20000) in a set, and for each point in the x-y plane want to determine which point from the set is closest. (Actually, the points are of different types, and I just want to know which type is closest. And the x-y plane is a bitmap, say 640x480.) From this answer to the question " All k nearest neighbors in 2D, C++ " I got the idea to make a grid. I created n*m C++ vectors and put the points in the vector, depending on which bin it falls into. The idea is that you only have to check the distance of the points in the bin, instead of all points. If there

2D KD Tree and Nearest Neighbour Search

为君一笑 提交于 2019-12-05 09:51:15
问题 I'm currently implementing a KD Tree and nearest neighbour search, following the algorithm described here: http://ldots.org/kdtree/ I have come across a couple of different ways to implement a KD Tree, one in which points are stored in internal nodes, and one in which they are only stored in leaf nodes. As I have a very simple use case (all I need to do is construct the tree once, it does not need to be modified), I went for the leaf-only approach is it seemed to be simpler to implement. I