Description:
Considering taking a negative buffer by -91 of a Polygon,the result should maintain a distance of at least 91 units from the outer boundary of the original polygon.
But here's an unusual example:
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(g geometry);
INSERT INTO t1 VALUES(ST_GeomFromText('POLYGON ((142840271 214449730, 142840245 214449781, 142840188 214449866, 142840184 214449874, 142840172 214449869, 142840170 214449873, 142840103 214449835, 142840107 214449826, 142840058 214449801, 142840065 214449788, 142840037 214449770, 142839987 214449857, 142839983 214449855, 142839982 214449857, 142839972 214449851, 142839967 214449859, 142839920 214449835, 142839864 214449797, 142839866 214449794, 142839857 214449788, 142839930 214449661, 142839946 214449670, 142839953 214449658, 142839955 214449659, 142839967 214449665, 142840012 214449591, 142840029 214449592, 142840029 214449592, 142840036 214449580, 142840051 214449588, 142840049 214449587, 142840071 214449548, 142840128 214449580, 142840127 214449583, 142840193 214449618, 142840195 214449614, 142840203 214449620, 142840203 214449620, 142840211 214449626, 142840218 214449614, 142840221 214449615, 142840221 214449615, 142840221 214449615, 142840222 214449614, 142840269 214449643, 142840296 214449658, 142840296 214449659, 142840303 214449663, 142840303 214449663, 142840304 214449664, 142840300 214449671, 142840300 214449671, 142840296 214449680, 142840296 214449680, 142840292 214449686, 142840288 214449694, 142840289 214449695, 142840287 214449698, 142840291 214449700, 142840273 214449731, 142840271 214449730))'));
INSERT INTO t1 VALUES(ST_GeomFromText('POLYGON((0 0, 0 200, 200 200, 200 0, 0 0))'));
WITH data AS (
SELECT g AS geom, ST_Buffer(g, -91) AS buffered_geom FROM t1
)
SELECT ST_Contains(geom, buffered_geom),
ST_Distance(ST_ExteriorRing(geom), buffered_geom)
FROM data;
-- expected:{{t, 91},{t, 91}}
-- acutal :{{t, 82.92284054742444},{t,91}}
How to repeat:
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(g geometry);
INSERT INTO t1 VALUES(ST_GeomFromText('POLYGON ((142840271 214449730, 142840245 214449781, 142840188 214449866, 142840184 214449874, 142840172 214449869, 142840170 214449873, 142840103 214449835, 142840107 214449826, 142840058 214449801, 142840065 214449788, 142840037 214449770, 142839987 214449857, 142839983 214449855, 142839982 214449857, 142839972 214449851, 142839967 214449859, 142839920 214449835, 142839864 214449797, 142839866 214449794, 142839857 214449788, 142839930 214449661, 142839946 214449670, 142839953 214449658, 142839955 214449659, 142839967 214449665, 142840012 214449591, 142840029 214449592, 142840029 214449592, 142840036 214449580, 142840051 214449588, 142840049 214449587, 142840071 214449548, 142840128 214449580, 142840127 214449583, 142840193 214449618, 142840195 214449614, 142840203 214449620, 142840203 214449620, 142840211 214449626, 142840218 214449614, 142840221 214449615, 142840221 214449615, 142840221 214449615, 142840222 214449614, 142840269 214449643, 142840296 214449658, 142840296 214449659, 142840303 214449663, 142840303 214449663, 142840304 214449664, 142840300 214449671, 142840300 214449671, 142840296 214449680, 142840296 214449680, 142840292 214449686, 142840288 214449694, 142840289 214449695, 142840287 214449698, 142840291 214449700, 142840273 214449731, 142840271 214449730))'));
WITH data AS (
SELECT g AS geom, ST_Buffer(g, -91) AS buffered_geom FROM t1
)
SELECT ST_Contains(geom, buffered_geom),
ST_Distance(ST_ExteriorRing(geom), buffered_geom)
FROM data;