![]() vfunc = np.vectorize(lambda a: np.any(labelled_pts != labelled_pts, 2])) However you can then build a simple vectorisation function to test whether each item in the tree matches a point from a different group. Because you put in our original set there will always be at least one match. This returns an array of the same length as the incoming points, with each value in the array being a tuple of indexes of the found points in the tree. points_within_tolerance = tree.query_ball_point(labelled_pts, tolerance) You use the ball point algorithm to get all the points within tolerance of another set of points (which is conveniently also our input points). Remember that you don't want the labels themselves in the tree - they're used later on to classify results tree = (labelled_pts) You can now build a KDTree from the labelled points. Then, so you can process all the points in bulk but still know what group they're in, stack the arrays. You'll also need to specify a tolerance tolerance = 0.1 Np.sin(np.linspace(0., 2 * np.pi, num_pts)),Īll_trails = Points_c = points_a + np.random.random() - 0.5 Points_b = points_a + np.random.random() - 0.5 import numpy as npįor this example I'll dummy up some data, but take a look at numpy.loadtxt to read in your CSVs. This also assumes everything is in the same projection. This has the bonus of coping with more than two base data sets for comparison, though note this is not memory friendly - if you've got a lot of points you might need to do some work to make this more memory efficient. With a bit of work you can take this a bit further by stacking the points into a single array and playing with labelled groups. For example, if you have access to numpy and scipy you can use a KDTree to easily calculate points from trail A that are within some tolerance of points from trail B. But it's simple enough to do in Python if you're happy enough with the scripting. As said above, I too am not sure that an open source library exists to do this.
0 Comments
Leave a Reply. |