2

While creating inner buffers for polygons on postgres/postgis base- a set of few thousand- I received a strange result. Inner buffer for one of the polygons, that was not supposed to appear from logical point of view, showed up. What is more, it looked like flipped. I've made some more "research" in QGIS and noticed that polygons of certain rotation, with buffer of approx. 65% of one of the edges receive above buffer result. As seen in the picture, when rotated, polygon's buffer won't be generated. I tried regular QGIS tools (buffer) executed on shapefiles not on postgres table.

enter image description here

In the screenshot you can see polygons of different size and orientation to the north. All inner buffers are wrong - should not be present. One polygon that hasn't got inner buffer is just rotated copy of the other in the picture. That was enough for the QGIS "buffer" algorithm to work properly, and not generate buffer there.

The source problem is as follows:

POLYGON ((666360.09 429614.71, 666344.4 429597.12, 666358.47 429584.52, 666374.5 429602.33, 666360.09 429614.71)) 

in epsg:2180 , and -15m buffer for it.

It gives me wrong result - I guess

I tried to detect error using st_orientation( to check if these buffers have different vertices flow, they don't). I have also changed direction of base/source polygon vertices but it does't make any difference. Vertices seem to be moved according to buffer size and then used to form polygon. A bit larger or smaller inner buffor works fine. What am I missing?

5
  • 1
    In the screenshot You can see polygons of different size and orientation to the north . All inner buffers are wrong - should not be present. One polygon that hasn't got inner buffer is just rotated copy of the other in the picture. That was enough for the Qgis "buffer" algorithm to work properly, and not generate buffer there. The source problem is as follows: POLYGON ((666360.09 429614.71, 666344.4 429597.12, 666358.47 429584.52, 666374.5 429602.33, 666360.09 429614.71)) in epsg:2180 , and -15m buffer for it. It gives me wrong result - I guess
    – krav
    Aug 26, 2019 at 8:25
  • 1
    those buffers are inverted, -15 is larger than your polygon widths / 2, so it extends into the other direction; PostGIS creates vertices first and then polygonizes them!
    – geozelot
    Aug 26, 2019 at 19:31
  • Yes, that is what I wrote. But why then rotating polygon or changing a bit the buffer size works fine?
    – krav
    Aug 27, 2019 at 7:01
  • It works just 'fine' (inverted buffer) for me with the polygon you added to the question? what's your PostgreSQL/PostGIS version?
    – geozelot
    Aug 27, 2019 at 9:43
  • It's 9.6 64bits. You get inverted inner buffer, right? Why is it considered 'fine', when after rotation of polygon this buffer does't appear. For me it's lack of consistency. If I wanted to get inverted buffer I would like to use other tool 'inverted buffers tool':) . So maybe there is a way that I do not know -other function in postgis, or tool in QGIS? The result I am expectiong are 'eroded' polygons. Buffer tool won't give me that? Am I correct?
    – krav
    Aug 27, 2019 at 11:00

1 Answer 1

1

This is an issue with the GEOS library that QGIS uses to compute buffers. And it's also an issue with the JTS library that GEOS is based on (and for which I'm the project lead).

I've logged a JTS issue for this. At the moment I don't have an idea for a fix.

Can you provide some more polygon data that fails?

UPDATE: this is now fixed in JTS and GEOS.

2
  • Sory for late response. Sure, it's quite easy to generate those. I just draw a quadrangle shape rotated a bit, and set buffer to negative ~0,62* quadrangle edge : Polygon ((642767.2621341390768066 425022.96776744804810733, 644656.59197098040021956 423004.81998718564864248, 642531.09590453386772424 421523.41363784414716065, 640470.0088097978150472 423198.04690231714630499, 642767.2621341390768066 425022.96776744804810733)),epsg 2180, buffer -1686 [m];
    – krav
    Sep 23, 2019 at 13:34
  • Great! Thank You.
    – krav
    Oct 27, 2021 at 11:05

Your Answer

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

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