Calculate center of bunch of (Spatial Point) 3D cartesian points


I have bunch of cartesian-3D points. Is there a function/procedure to calculate center point, positioned after calculating distances from each node? I want to create a new node, that would represent the points it was calculated from.



There's no reason to calculate distances between points. Instead you can deconstruct each point and calculate the average of each individual dimension. Try out the code below. Put any number of points in there that you desire and it will provide you with the average of all 3 dimensions.

WITH [point({ x: 2.3, y: 4.5, z: 2 }), point({ x: 2.3, y: 4.5, z: 4 })] AS points
UNWIND points AS point
WITH avg(point.x) AS avgx, avg(point.y) AS avgy, avg(point.z) AS avgz
RETURN point({ x: avgx, y: avgy, z: avgz }) AS avgpoint;