Questions tagged [scipy-spatial]

103 questions
27
votes
6 answers

Efficient distance calculation between N points and a reference in numpy/scipy

I just started using scipy/numpy. I have an 100000*3 array, each row is a coordinate, and a 1*3 center point. I want to calculate the distance for each row in the array to the center and store them in another array. What is the most efficient way to…
D. Huang
  • 445
  • 1
  • 4
  • 5
9
votes
2 answers

Interpolation with Delaunay Triangulation

Having a cloud point shaped like some sort of distorted paraboloid, I would like to use Delaunay Triangulation to interpolate the points. I have tried other techniques (f.ex. splines) but did not manage to enforce the desired behavior. I was…
NoIdeaHowToFixThis
  • 4,484
  • 2
  • 34
  • 69
8
votes
2 answers

Increasing efficiency of barycentric coordinate calculation in python

Background: I'm attempting to warp one face to another of a different shape. In order to warp one image to another, I'm using a delaunay triangulation of facial landmarks and warping the triangles of one portrait to the corresponding triangles of…
6
votes
1 answer

Delaunay Triangulation simplices - scipy

I was reading about Delaunay (scipy) and came across the code: import numpy as np points = np.array([[0, 0], [0, 1.1], [1, 0], [1, 1]]) from scipy.spatial import Delaunay tri = Delaunay(points) import matplotlib.pyplot as…
Arun
  • 2,222
  • 7
  • 43
  • 78
6
votes
1 answer

What Do Different Link Colors Mean In A Scipy Dendrogram?

I have the following dendrogram made with SciPy: # create the dendrogram from scipy.cluster import hierarchy as hc from scipy.stats import spearmanr as sp import matplotlib.pyplot as plt %matplotlib inline corr =…
Jonathan Bechtel
  • 3,497
  • 4
  • 43
  • 73
6
votes
1 answer

How to use scipy.interpolate.LinearNDInterpolator with own triangulation

I have my own triangulation algorithm that creates a triangulation based on both Delaunay's condition and the gradient such that the triangles align with the gradient. This is an example output: The above description is not relevant to the question…
johnbaltis
  • 1,413
  • 4
  • 14
  • 26
6
votes
1 answer

Why cdist from scipy.spatial.distance is so fast?

I wanted to create a distance proximity matrix for 10060 records/ points, where each record/point has 23 attributes using euclidean distance as metric. I wrote code using nested for loops to calculate distance between each point(leading to…
Sushodhan
  • 400
  • 1
  • 6
  • 16
5
votes
0 answers

Why scipy 'cKDTree' is slower than 'cdist' for finding the nearest point?

I've been told throughout many references that KDTree is a fast way to find nearest neighbors for large data. My current issue is to find the nearest points in X for a given data A. To elaborate, currently, X has 1,000,000 numerical data and A…
Cody Chung
  • 629
  • 1
  • 6
  • 15
4
votes
2 answers

Python's scipy spatial KD-tree is slower than brute force euclidean distances?

I've quickly checked the performance of building a tree and querying it versus just calculating all the euclidean distances. If I query this tree for all other points within a radius, shouldn't it vastly outperform the brute force approach? Does…
Robin De Schepper
  • 4,942
  • 4
  • 35
  • 56
4
votes
3 answers

Find all points within distance 1 of specific point in 2D numpy matrix

I want to find a list of points that are within range 1 (or exactly diagonal) of a point in my numpy matrix: For example say my matrix m is: [[0 0 0 0 0] [0 0 0 0 0] [0 0 1 0 0] [0 0 0 0 0] [0 0 0 0 0]] I would like to obtain a list of tuples…
4
votes
1 answer

Centroidal Voronoi tesselations around obstacles

I am trying to implement a Centroidal Voronoi tessellation algorithm in a bounded rectangular space such that, the bounding rectangle has a number of obstacles(polygons) in it. The below code gives the centroidal voronoi tessellations in a bounding…
3
votes
0 answers

Orientation of Voronoi regions calculated using scipy.spatial.Voronoi

I wonder if Voronoi regions calculated using scipy are oriented clockwise?
TZDM
  • 31
  • 3
3
votes
1 answer

Understanding ridge vertices returned by `scipy.spatial.Voronoi` in 3D

I don't understand the return format of the ridge vertices for the function scipy.spatial.Voronoi. When using this function in 2D, the vertices are in pairs for one ridge, which is the format I expect, but in 3D, the number of vertices in ridges…
Takyon
  • 59
  • 6
3
votes
1 answer

SciPy cdist Speed Difference

I am curious as to why the following cdist differ so much in time even though they produce the same results: import numpy as np from scipy.spatial.distance import cdist x = np.random.rand(10_000_000, 50) y = np.random.rand(50) result_1 = cdist(x,…
slaw
  • 6,591
  • 16
  • 56
  • 109
3
votes
1 answer

scipy.spatial.transform.Rotation Array of rotation vs Stack inside the same object

In a project I have to store a sequence of successive rotations of an object in python. I intend to store them using scipy.spatial.transform.Rotation objects. I have noticed that two options are available. I store a multitude of Rotation object in…
LNiederha
  • 911
  • 4
  • 18
1
2 3 4 5 6 7