[GIS] Creating polygon from exterior points using PostGIS

concave hullpointpoint-of-interestpolyline-creationpostgis

How to convert points data to polygon, enter image description here so as to form polygon from exterior point as shown above

Best Answer

I would create a geometry collection from the points using st_collect(): http://postgis.net/docs/ST_Collect.html

Then I would create convex hull from the point collection: http://postgis.net/docs/ST_ConcaveHull.html

If you have a table of point geometries called testpoints where geometry column name was the_geom, this should create the polygon that you are looking for:

SELECT st_astext(st_concavehull(st_collect(the_geom),0.99))
FROM myschema.testpoints;