I have this points represented as geom:

enter image description here

And when I apply: ST_MakeLine(points.geom) I got this:

enter image description here

When I need something like closing/bounding line (and even better the whole area as 1 geom):

enter image description here

This is how I get the points for example:

SELECT DISTINCT (ST_DumpPoints(buildings.geom)).geom  --AS geom
FROM buildings
WHERE ST_DWithin(buildings.geom, ST_GeomFromText('POINT(lon lat)', 4326), radius)


Applying ST_ConcaveHull(ST_Collect(vertices.geom), 0.99, false) resulted almost the solution:

enter image description here

The reason is as documented here: "he basic approach is that it first creates a convexhull of the geometry and then uses the ST_ClosestPoint function introduced in PostGIS 1.5 to cave in the hull to transform it into a concave hull. That's the basic idea". We can see that the points not connected properly are those where the issue with the closest point is Misleading...

  • seeing your case, it seems it is impossible, unless you have ordered points, that is points have some number corresponding to the order in which they are to be drawn..
    – vinayan
    Aug 15, 2015 at 10:26
  • I get the points from regular PostGIS queries. How can I make sure they returned in order? In the sense of geographical metric...
    – michael
    Aug 15, 2015 at 10:27
  • so how you got this points from the query could be helpful to those who may answer..
    – vinayan
    Aug 15, 2015 at 10:28
  • @vinayan Please see my edit
    – michael
    Aug 15, 2015 at 10:30
  • Have you seen postgis.net/docs/ST_ConcaveHull.html? Aug 15, 2015 at 10:38

1 Answer 1


What you want to do isn't really possible in, a general sense, without giving the database more information. It might be clear to a human what the correct solution is, but the machine isn't quite there yet.

I tried ST_ConcaveHull with 0.99, and got these two results:

ST_ConcaveHull result comparison

The difference is a small perturbation of the inside point on the right (I exaggerated it for effect.)

vinayan's suggestion, that you order the points, is, I think, the right one. You could do that by assigning an ID to each one and ordering them on it.

Another thing you could try is a Delaunay triangulation. Build the triangulation, then remove edges greater than a certain length from the boundary until the desired shape emerges. This would still require some intervention on your part. (I believe this is similar to the idea behind alpha shapes.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.