STPointOnSurface()
seems to always return the same point. How can I generate a random point located within the interior of geometry in SQL Server?
Asked
Active
Viewed 643 times
3
1 Answers
0
Use a CTE with the extents of your surface defined in the WHERE clause, but add a row number for each point returned in your SELECT. Then query your CTE, but choose the point with a random row number using the row number you assigned in the CTE.
This assumes that you are speaking about a surface that is defined by a point cloud and not by borders/edges. If your data is defined by borders/edges then you can use a simple distance formula with a random modifier.

Mr. Mascaro
- 2,693
- 1
- 11
- 18
-
The surfaces are defined by borders/edges. I do not think a distance function will work because the shapes are irregular. – bre Sep 23 '14 at 08:59