[postgis-users] Unexpected behaviour in ST_Buffer

Regina Obe lr at pcorp.us
Thu Mar 16 13:04:53 PDT 2023


> Hello, there is a behaviour that I didn't expect with ST_Buffer.

> Using ST_Buffer on any LINESTRING with a start point the same as the end
> point, for on example this circle:

> In Postgis version 2.5, the result was an area encircling the input
circle,
> with a radius 7 meters bigger than the input. This is what I would expect.

> However, in Postgis version 3.3, the result is a ring that appears to be 7
> meters wide and does not include the input polygon. I think this behaviour
> only happens when the radius passed to ST_Buffer is bigger than the radius
> of the input LINESTRING.

I see what you mean, and yes a positive buffer of a linestring should always
contain the original geometry.
I can't think of an instance when it shouldn't even if the buffer is longer
than the length.

SELECT ST_Intersects(ST_Buffer(geog, 7.0), geog) ,
ST_Distance(ST_Buffer(geog,7.0), geog)
FROM (SELECT 'SRID=4326;LINESTRING(
  15.209907 48.3882267,
  15.2098971 48.3882238,
  15.2098892 48.3882189,
  15.2098842 48.3882126,
  15.2098826 48.3882055,
  15.2098846 48.3881985,
  15.20989 48.3881923,
  15.2098982 48.3881877,
  15.2099082 48.3881851,
  15.209919 48.3881848,
  15.2099288 48.3881868,
  15.2099372 48.3881907,
  15.2099433 48.3881962,
  15.2099465 48.3882026,
  15.2099465 48.3882095,
  15.2099432 48.3882159,
  15.209937 48.3882214,
  15.2099281 48.3882254,
  15.2099177 48.3882272,
  15.209907 48.3882267
)'::geography AS geog) AS f;

Yields:
st_intersects | st_distance
---------------+-------------
 f             |  2.06699802
(1 row)
The above returns false and visually it is clear it doesn't contain the
input string.

This is running:

POSTGIS="3.3.2 3.3.2" [EXTENSION] PGSQL="150" GEOS="3.11.1-CAPI-1.17.1"
SFCGAL="SFCGAL 1.4.1, CGAL 5.3, BOOST 1.78.0" PROJ="7.2.1" GDAL="GDAL 3.4.3,
released 2022/04/22" LIBXML="2.9.9" LIBJSON="0.12" LIBPROTOBUF="1.2.1"
WAGYU="0.5.0 (Internal)" TOPOLOGY RASTER

Unfortunately I don't have a PostGIS 2.5 readily handy.  Can you provider
the: 

SELECT postgis_full_version();

Of both your PostGIS 2.5 and PostGIS 3.3.  This could be a GEOS bug rather
than a PostGIS one.
Could also be a proj issue since ST_Buffer is one of those functions that
transforms to geometry before doing buffer.

Thanks,
Regina









More information about the postgis-users mailing list