Postgis ST_Distance (Minimum Distance Calculation)

postgis, postgresql

Solution

It looks like you want the distance to the polygon shell, or the exterior ring. If you have a POLYGON try finding the distance to `ST_ExteriorRing(poly_geom)`. For MULTIPOLYGONs, see manual page for ST_ExteriorRing.

Problem

I have a geometry of type polygon , I am calculating minimum distance of a POINT may be inside of polygon geometry(made up of 360 points as a closed geometry) or outside of polygon geometry with ST_Distance method of postgis , I am getting exact distance when POINT is outside the geometry but getting 0 as Distance if POINT is inside the geometry , I want minimum distance from the point with the closest point of polygon geometry whether the POINT is inside the geometry or outside the geometry.

Original source