2

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?

2

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

Mitre joins Square endcaps

ST_Buffer

    SELECT ST_Buffer(
      ST_GeomFromText(
        '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. – Marc Compte Jan 11 at 12:55
  • Thanks, corrected the answer! – Fjellrev Jan 11 at 13:05

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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