A follow on from this question: ST_3DClosestPoint returning multiple points
1) I have a xyz target point stored as a geom, I want to update the row with the 3Ddistance to the nearest obs point in another table. So find the nearest obs point and then update the target point with the distance.
expected result for the target point: id|geom|3Ddistance_To_Nearest_Point_In_Obs_Table
obs table: id|geom e.g. 100 records
2) To complicate matters, I also want to select n-neighbours from the obs table (lets say 10 for example) and calculate the average distance and update the target table.
expected target result: id|geom|average_3Ddistance
I've been trying to alter the former example, but no joy, any ideas?
Thanks