[GIS] Postgis identify points on the polygon border

polygonpostgis

I have points geom in gid,pt_geom and polygon geom in gid,pl_geom. Some of the points are inside polygon and some are outside polygon, others are on the polygon boundary.

enter image description here

Is there any way to identify those points on the polygon by using PostGIS functions (e.g. ST_contains() or ST_Distance())?

Maybe Select points.gid from points inner join polygon on st_contains(polygon.the_geom,points.the_geom).

Best Answer

Select points.gid 
from points inner join polygon 
on st_dwithin(st_exteriorring(polygon.the_geom),points.the_geom,0.001)