Answered by:
Hausdorff Distance

SQL Server don't have Hausdorff Distance function by default, like PostGIS ?
How can I code a function which gets as input two polygons and returns a float with Hausdorff distance?
I'm using SQL Server "Denali".
Sincerely,João Vicente
 Edited by Joao M Vicente Tuesday, October 18, 2011 10:27 AM
Question
Answers

No, there is no inbuilt function.
The ST_Hausdorff function in PostGIS does not give a true Hausdorff distance between two geometries  it only considers the distance measured from the vertices of one of the geometries to the other (as noted at http://postgis.refractions.net/docs/ST_HausdorffDistance.html).
Therefore, you could rewrite this fairly easily in a SQLCLR procedure that examined each of the vertices of one supplied geometry (using STPointN() up to STNumPoints()) and determined the distance from that vertex to any point of the second geometry (using STDistance()). The maximum value of STDistance() returned from any vertex in one geometry to any point in the other geometry is the "discrete Hausdorff distance" equivalent to that which you'd get from PostGIS.
twitter: @alastaira blog: http://alastaira.wordpress.com/ Marked as answer by Peja Tao Thursday, October 20, 2011 8:08 AM
All replies

No, there is no inbuilt function.
The ST_Hausdorff function in PostGIS does not give a true Hausdorff distance between two geometries  it only considers the distance measured from the vertices of one of the geometries to the other (as noted at http://postgis.refractions.net/docs/ST_HausdorffDistance.html).
Therefore, you could rewrite this fairly easily in a SQLCLR procedure that examined each of the vertices of one supplied geometry (using STPointN() up to STNumPoints()) and determined the distance from that vertex to any point of the second geometry (using STDistance()). The maximum value of STDistance() returned from any vertex in one geometry to any point in the other geometry is the "discrete Hausdorff distance" equivalent to that which you'd get from PostGIS.
twitter: @alastaira blog: http://alastaira.wordpress.com/ Marked as answer by Peja Tao Thursday, October 20, 2011 8:08 AM
