# Is there a way to find the closet point to a poly, ON the poly?

• ### Question

• Hi folks,

lets say i have a linestring and a POI like this ...

is there a way i can calculate the closest point on that linestring, to that POI? In this picture, it's where the RED ARROW is pointing, on that linestring.

-Pure Krome-
Monday, January 24, 2011 4:37 AM

• Hi Krome,

The title of your post said closest point to a poly , but then your image shows a a line - is that the exterior ring of the poly?

Either way, you'll probably find the discussion here and the proposed workaround by JasonFollas helpful:

Beginning Spatial with SQL Server http://www.apress.com/book/view/1430218290
• Marked as answer by Monday, January 24, 2011 10:58 PM
Monday, January 24, 2011 8:56 AM

### All replies

• Hi Krome,

The title of your post said closest point to a poly , but then your image shows a a line - is that the exterior ring of the poly?

Either way, you'll probably find the discussion here and the proposed workaround by JasonFollas helpful:

Beginning Spatial with SQL Server http://www.apress.com/book/view/1430218290
• Marked as answer by Monday, January 24, 2011 10:58 PM
Monday, January 24, 2011 8:56 AM
• Hi Tanoshimi :)

yep - perfect! that's exactly what I was after ... and it's also in Denali! ShortestLineTo() :) Cheers to Ed for the blogpost about it. (But i have to wait for Denali, though).

I'll use Jason Follas' workaround. tres bien!

-Pure Krome-
Monday, January 24, 2011 10:59 PM
• Oh - as a side note, for Jason's workaround, he does an STIntersection() .. in the end of that Sql text. For polys that were linestrings, I always got a Collection Empty - because I read somewhere that STIntersection will always returns an empty collection if the target is a 2d poly or linestring. So i just STBuffer(0.1) to make sure any linestrings are now polys.
-Pure Krome-
Monday, January 24, 2011 11:40 PM