I am trying to expand a polygon in a particular manner with PostGIS. I need a new geometry that is a bit like a Buffer, except Buffer produces rounded corners (lots of vertices) when using it on a square and I need a new square whose sides are N meters away from the inner/original square (and still have only 4 vertices).

My first approach was to use a Buffer and then Simplify, but that is not producing the desired result.

I checked ST_Expand but this returns a BBOX, so it does not work either when the square is not perfectly N-S/E-W oriented nor will it work on irregular polygons.

I also looked into ST_Scale, but this uses a multiplying factor which I don't know how to find out based on a metric distance.

Another function I've looked into is ST_Affine to see if I can scale and translate in one go, but I got no clue how to find out the values I should use in this function.

I have searched and found out nothing. Has anyone done this with PostGIS? then, how?


1 Answer 1


Use join=mitre mitre_limit=b where b = buffer distance (and possibly endcap=square)

Mitre joins Square endcaps


    SELECT ST_Buffer(
        'LINESTRING(5 5,15 15,15 5)'
           ), 1, 'endcap=square join=mitre mitre_limit=1');
  • 1
    Actually I had to use a mitre_limit equal to the buffered distance, otherwise in my square test I still got a polygon with more than 4 vertices. Jan 11, 2019 at 12:55

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.