[postgis-users] Closest point on a POLYGON to a given POINT

Maxime van Noppen maxime at altribe.org
Mon Oct 12 07:58:34 PDT 2009


Juergen Lorenz Simon wrote:
> Hi,
> 
> I have a nut to crack and i'm not finding anything suitable in the
> PostGIS documentation. The problem is as follows:
> 
> I have a POLYGON G and a POINT P. I'd like to find the closest point to
> P on G (not in, ON). Is there a quick way of doing this with the
> build-in functions? Or is there some plsql routine I can use?

Hi,

You could take the various rings of your polygon with ST_DumpRings, find
the closest point with ST_Line_Locate_Point and ST_Line_Interpolate_Point.

> PS: Coming to think of it: is there some open source repository for
> PostGIS code?

There is the wiki :

http://trac.osgeo.org/postgis/wiki/UsersWikiMain

-- 
Maxime



More information about the postgis-users mailing list